Skip to content
Snippets Groups Projects
Commit ea30498e authored by Susan Yuen's avatar Susan Yuen
Browse files

Wrote unit, warrior, player classes and add functions to GameFunction

parent 256ef57c
No related branches found
No related tags found
No related merge requests found
......@@ -3,9 +3,26 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
namespace Controller
{
class GameFunction
{
// might not need; check if enemyUnitsInRange returns an empty list
public bool isAnEnemyUnitInRange(Unit unit) { return false; }
// returns all enemy units in range of the specified unit
public LinkedList<Unit> enemyUnitsInRange(Unit unit) { return [0]; }
// checks if current turn is over yet (no more possible moves)
public bool isTurnOver(Player player) { return false; }
// checks if specified unit can perform actions
public bool hasUnitFinishedActions(Unit unit) { return false; }
// checks lose/win conditions to determine if game is over
public bool isGameOver() { return false; }
}
}
......@@ -7,5 +7,27 @@ namespace Model
{
class Player
{
private LinkedList<Unit> ownedUnits; // units that the player owns
private bool moving; // indicates if it is currently the player's turn
public LinkedList<Unit> getUnits()
{
return ownedUnits;
}
public bool isMoving()
{
return moving;
}
// Tells whether a specified unit is owned by the player
public bool ownsUnit(Unit unit)
{
if (ownedUnits.Contains(unit))
{
return true;
}
return false;
}
}
}
......@@ -7,5 +7,19 @@ namespace Model
{
interface Unit
{
bool isAlive(); // whether unit is dead or alive
int getHp(); // returns unit's HP
int getStr(); // returns unit's strength
int getInt(); // returns unit's intelligence
int getSkill(); // returns unit's skill
int getSpeed(); // returns unit's speed
int getDefense(); // returns unit's defense
int getResistance(); // returns unit's resistance
int getCriticalRate(); // returns unit's critical rate
Weapon[] getEquipableWeapons(); // returns array of equipable weapons
int getLevel(); // returns unit's level
UnitType getClass(); // returns unit's class (warrior, mage, archer)
}
enum UnitType { Warrior, Archer, Mage }; //defines the possible classes of a unit
}
......@@ -5,7 +5,84 @@ using System.Text;
namespace Model
{
class Warrior
class Warrior : Unit
{
private bool alive; // whether unit is alive or dead
private int hp;
private int str;
private int intelligence;
private int skill;
private int speed;
private int defense;
private int resistance;
private int criticalRate;
private int level;
private Weapon[] equipableWeapons;
public Warrior(Player p)
{
// TODO: setup pre-determined stats for warrior
player = p;
}
public bool isAlive()
{
return alive;
}
public int getHp()
{
return hp;
}
public int getStr()
{
return str;
}
public int getInt()
{
return intelligence;
}
public int getSkill()
{
return skill;
}
public int getSpeed()
{
return speed;
}
public int getDefense()
{
return defense;
}
public int getResistance()
{
return resistance;
}
public int getCriticalRate()
{
return criticalRate;
}
public int getLevel()
{
return level;
}
public Weapon[] getEquipableWeapons()
{
return equipableWeapons;
}
public UnitType getClass()
{
return UnitType.Warrior;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment