Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Test
- {
- class Skill
- {
- private int _damage;
- private int _mp;
- private int _reArmor;
- private string _name;
- public int Damage { get => _damage; set => _damage = value; }
- public int Mp { get => _mp; set => _mp = value; }
- public int ReArmor { get => _reArmor; set => _reArmor = value; }
- public string Name { get => _name; set => _name = value; }
- public Skill()
- {
- }
- public Skill(string name,int damage, int mp, int rearmor)
- {
- Damage = damage;
- Name = name;
- Mp = mp;
- ReArmor = rearmor;
- }
- public void ShowInfoSKill()
- {
- Console.WriteLine(Name + "(mana = " + Mp + ", dame = " + Damage + ", reduce armor = " + ReArmor + ")");
- }
- }
- class Player
- {
- private string _name;
- private int _MP;
- private int _HP;
- private int _armor;
- private List<Skill> _SkillList;
- public string Name { get => _name; set => _name = value; }
- public int MP { get => _MP; set => _MP = value; }
- public int HP { get => _HP; set => _HP = value; }
- public int Armor { get => _armor; set => _armor = value; }
- public List<Skill> SkillList { get => _SkillList; set => _SkillList = value; }
- public Player()
- {
- }
- public Player(string name, int hp, int mp, int armor,List<Skill> skillList)
- {
- Name = name;
- HP = hp;
- MP = mp;
- Armor = armor;
- SkillList = skillList;
- }
- public void ShowInfoPlayer()
- {
- Console.WriteLine("HP: " + HP);
- Console.WriteLine("MP: " + MP);
- Console.WriteLine("Armor: " + Armor);
- }
- public void get_dame(Skill skill)
- {
- HP -= skill.Damage + Math.Max(0, Armor - skill.ReArmor);
- }
- public bool dead()
- {
- return HP <= 0;
- }
- public bool CheckMana(Skill skill)
- {
- return skill.Mp <= MP;
- }
- public void ShowAllSkill(List<Skill> SkillList)
- {
- for (int i = 0; i < SkillList.Count; i++)
- {
- Console.WriteLine("Skill thu " + i);
- SkillList[i].ShowInfoSKill();
- }
- }
- public Skill UseSKill()
- {
- int i;
- do
- {
- this.ShowAllSkill(SkillList);
- Console.WriteLine("choose skill");
- i = int.Parse(Console.ReadLine());
- if (CheckMana(SkillList[i]))
- {
- MP -= SkillList[i].Mp;
- return SkillList[i];
- }
- else
- {
- i = -1;
- Console.WriteLine("Not enough mana");
- }
- }
- while (i < 0 || i >= SkillList.Count);
- return null;
- }
- }
- class Monster
- {
- private string _name;
- private int _HP;
- private int _Armor;
- private List<Skill> sKillList;
- public int HP { get => _HP; set => _HP = value; }
- public int Armor { get => _Armor; set => _Armor = value; }
- internal List<Skill> SkillList { get => sKillList; set => sKillList = value; }
- public string Name { get => _name; set => _name = value; }
- public Monster()
- {
- }
- public Monster(string name,int hp,int mp, int armor,List<Skill> skilllist)
- {
- HP = hp;
- Armor = armor;
- SkillList = skilllist;
- Name = name;
- }
- public bool Dead()
- {
- return this.HP <= 0;
- }
- public void get_dame(Skill skill)
- {
- HP -= skill.Damage + Math.Max(0, this.Armor - skill.ReArmor);
- }
- public void ShowInfoMonster()
- {
- Console.WriteLine("HP:" + HP);
- Console.WriteLine("Armor: " + Armor);
- }
- public void ShowAllSkill(List<Skill> SkillList)
- {
- for (int i = 0; i < SkillList.Count; i++)
- {
- Console.WriteLine("Skill thu " + i);
- SkillList[i].ShowInfoSKill();
- }
- }
- public Skill UseSKill()
- {
- int i;
- do
- {
- this.ShowAllSkill(SkillList);
- Console.WriteLine("choose skill");
- i = int.Parse(Console.ReadLine());
- if (i == 0)
- {
- return SkillList[i];
- }
- }
- while (i != 0);
- return null;
- }
- }
- class BattleField
- {
- private Player _a;
- private Monster _b;
- private bool _isPlayerTurn;
- public bool IsPlayerTurn { get => _isPlayerTurn; set => _isPlayerTurn = value; }
- internal Player A { get => _a; set => _a = value; }
- internal Monster B { get => _b; set => _b = value; }
- public BattleField()
- {
- }
- public BattleField(Player a, Monster b, bool isplayerturn)
- {
- A = a;
- B = b;
- IsPlayerTurn = isplayerturn;
- }
- public void ChangeTurn()
- {
- IsPlayerTurn = !IsPlayerTurn;
- }
- public string Winner()
- {
- if (A.dead())
- {
- return B.Name;
- }
- else if (B.Dead())
- {
- return A.Name;
- }
- return null;
- }
- public void ShowResult()
- {
- Console.WriteLine("Winner is " + Winner());
- }
- public void Fight()
- {
- while (A.HP > 0 && B.HP > 0)
- {
- if (IsPlayerTurn)
- {
- Console.WriteLine("===================");
- Console.WriteLine("Luot nguoi choi");
- A.ShowInfoPlayer();
- Console.WriteLine("===================");
- B.get_dame(A.UseSKill());
- Console.WriteLine("===================");
- ChangeTurn();
- }
- else
- {
- Console.WriteLine("===================");
- Console.WriteLine("Luot quai vat");
- B.ShowInfoMonster();
- Console.WriteLine("===================");
- A.get_dame(B.UseSKill());
- Console.WriteLine("===================");
- ChangeTurn();
- }
- }
- ShowResult();
- }
- }
- class RunMain
- {
- static void Main(string[] args)
- {
- Skill skill1 = new Skill("Danh chay", 30, 0, 0);
- Skill skill2 = new Skill("Ban ten", 100, 30, 10);
- Player a = new Player("Cung thu", 200, 150, 10,new List<Skill>{ skill1, skill2 });
- Skill skill3 = new Skill("Danh chay", 40, 0, 0);
- Skill skill4 = new Skill("Ban ten", 100, 50, 30);
- Player b = new Player("Hiep si", 150, 100, 20, new List<Skill> { skill3, skill4 });
- Skill skill5 = new Skill("Thoi lua", 30, 0, 0);
- Monster c = new Monster("Ho", 500,0, 20,new List<Skill> { skill5 });
- BattleField War = new BattleField(a, c, true);
- War.Fight();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement