Giter VIP home page Giter VIP logo

battlewind's Introduction

Todo

!CLEANUP LEFT!

[ ] Add r/w to files in a locked CSV format

[ ] Socket programming + multi-party teams

[ ] Multi-map systems instead of single, big map

[ ] Add story line and more complexity re: objects, characters etc

[ ] Improve and debug battles

[ ] Allow PvP battles

Note: Server code should maintain a locked instance of the CSV file for movement and such and is updated on every input.

Files


A brief description of each file and what it does

Battle.java - A class to handle the battle between the hero and the monster. Can have one-to-one attack as chosen by user. A new instance is created when a battle is initiated in COMMON grounds. Local variable copies are maintained for speed

ManualHandler.java - A fallback handler when the readHandler fails. Only use for suspected corrupt files.

Market.java - A Market module to handle all market interactions.

gameData.java - A local DB-type storage for live game data.

readHandler.java - Handles read/write of data files.

Characters.java - Defines behvaiour and attributes of Heroes and Monsters (both are extended subclasses of Character class.

Map.java - Defines the behvaiour on Map. Each map is a 2D array of Tiles.

PrettyPrint.java - A simple processor to handle beautified printing. Not essential.

itemClass.java - Used to handle Item storage, inventory and such. Heavily extendible.

Maps

Every Tile has a few essential members such as type (enum), x co-ordinate and y co-ordinate. Another important aspect is the isPlayer boolean that let's the parser know if there are any players on current tile. getTileImage() - Parses current tile and returns a certain way the tile is to be printed. The Map is then a 2D array of Tiles. This allows for extendibility and modularity. All maps are inherently randomized.

Heroes

All heroes are an extended subclass of the Character class. GameData stores an instance of chosen heroes. readHandler keeps an archive of all heroes. Heroes can call attack() and spell(). They can buy and sell in markets too. For simplicity, the spells are also stored here (in the Character superclass).

Monsters

All monsters are an extended subclass of the Character class. Every Battle instance stores a randomly chosen roster of Monsters (level matched) in local scope. They're destroyed after battle is over.

Item Class

Stores all the potions, armours and weapons. Every instance of market and hero calls these things from here.

Read Handler and Manual Handler

These are used to read data from the txt files. They then store it in readHandler class. If anything fails, it calls manualHandler, which then makes ammends. For me, dragons.txt failed, so I've called it via manualHandler, but only after trying it with readHandler.

Market

Markets are places where merchants sell and buy a bunch of things. Uses in-game currency called Gold. Each hero has a certain amount of Gold that they can use. Defeating a monster gets them some gold. Losing a hero means losing all their gold.

Battle

Can have directed attacks/spells towards a certain monster. Individual heroes can die too. Winning gets every hero certain amount of experience based on level of involvement.

Notes


  1. Files to be parsed should be stored in gameUtils, for parser class to read class

  2. Bonus Done

    • Probability of encountering an enemy reduces if hero has a repelling item
    • Prettified printing
    • Data read from txt
    • Map size modifiable

Rules

Hero’s spell damage = 𝑠𝑝𝑒𝑙𝑙_π‘π‘Žπ‘ π‘’_π‘‘π‘Žπ‘šπ‘Žπ‘”π‘’ + ( 𝑑𝑒π‘₯π‘‘π‘’π‘Ÿπ‘–π‘‘π‘¦ 10000 ) Γ— 𝑠𝑝𝑒𝑙𝑙_π‘π‘Žπ‘ π‘’_π‘‘π‘Žπ‘šπ‘Žπ‘”π‘’ β€’ HP of monsters and heroes = 𝑙𝑒𝑣𝑒𝑙 Γ— 100 When a hero levels up, this formula is used to reset their HP. β€’ MP of the heroes when they level up = π‘π‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘_π‘šπ‘Žπ‘›π‘Ž Γ— 1.1 β€’ Hero’s attack damage (with weapon) = (π‘ π‘‘π‘Ÿπ‘’π‘›π‘”π‘‘β„Ž + π‘€π‘’π‘Žπ‘π‘œπ‘›_π‘‘π‘Žπ‘šπ‘Žπ‘”π‘’) Γ— 0.05 β€’ Hero’s dodge chance = π‘Žπ‘”π‘–π‘™π‘–π‘‘π‘¦ Γ— 0.002 β€’ Monster’s dodge chance = π‘‘π‘œπ‘‘π‘”π‘’_π‘β„Žπ‘Žπ‘›π‘π‘’ Γ— .01 β€’ Experience points to level up = β„Žπ‘’π‘Ÿπ‘œ_π‘π‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘_𝑙𝑒𝑣𝑒𝑙 Γ— 10 β€’ When a hero levels up all of their skills increase by 5% and their favored skills increase by an extra 5%. β€’ At the end of each round of a battle the heroes regain 10% of their HP and 10% of their MP. That is, 𝐻𝑃 = 𝐻𝑃 Γ— 1.1 and 𝑀𝑃 = 𝑀𝑃 Γ— 1.1 β€’ Hero gold gain = π‘šπ‘œπ‘›π‘ π‘‘π‘’π‘Ÿ_𝑙𝑒𝑣𝑒𝑙 Γ— 100 for heroes who did not faint β€’ Hero experience gain = π‘›π‘’π‘šπ‘π‘’π‘Ÿ_π‘šπ‘œπ‘›π‘ π‘‘π‘’π‘Ÿπ‘  Γ— 2 β€’ Monster’s skill loss caused by spell effect = π‘Žπ‘“π‘“π‘’π‘π‘‘π‘’π‘‘π‘ π‘˜π‘–π‘™π‘™ Γ— 0.1 β€’ Monster’s level = level of highest-level hero in the party β€’ Items sell for half of their purchase price. β€’ The party size is between 1 and 3 heroes

How to compile and run


  1. Navigate to src (cd src)

  2. Run the following instructions:

    javac -d gameUtils *.java cd ../gameUtils java Main

Game Example


Loading data, please wait...
  <=======]}======
    --.   /|
   _\"/_.'/
 .'._._,.'
 :/ \{}/
(L  /--',----._
    |          \\
   : /-\ .'-'\ / |
snd \\, ||    \|
     \/ ||    ||
Welcome to Legends: Monsters and Heroes
Enter size of map:
8
How many heroes?
1
Which type of hero would you like?
1. Warrior 	 2. Paladin 	 3. Sorcerer
2
Name | mana | strength | agility | dexterity | starting money | starting experience
Parzival | 300 | 750 | 650 | 700 | 2500 | 7
Sehanine_Moonbow | 300 | 750 | 700 | 700 | 2500 | 7
Skoraeus_Stonebones | 250 | 650 | 600 | 350 | 2500 | 4
Garl_Glittergold | 100 | 600 | 500 | 400 | 2500 | 5
Amaryllis_Astra | 500 | 500 | 500 | 500 | 2500 | 5
Caliber_Heist | 400 | 400 | 400 | 400 | 2500 | 8
Which Paladin would you like?
1
Name: Sehanine_Moonbow Level: 0 Exp: 7 HP: 0 Base Damage: 750 Mana: 300 Strength: 750 Agility: 700 Dexterity: 700 Gold: 0
Your team:
0: Name: Sehanine_Moonbow | Level: 0 | Damage: 750 | Defense: 0 | Dodge Chance: 0 | Gold: 0
Loading data, please wait...
YOU                           
                  (M)         
            (M)   (M)      (M)
               (M)      (M)   
                        (M)   
                              
                              
                        (M)   
                              
                             

battlewind's People

Contributors

abhinavmir avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.