public string AttackController(CanCauseDamage attack, Enemy receive) { string _result = null; _result = attack.Hit(receive) + Environment.NewLine; _result += EnemyManager.Instance.Attack(); return(_result); }
/// <summary> /// Process the attack command and return the result of attack /// </summary> /// <param name="h">hero</param> /// <param name="text">command</param> /// <returns>result of attack</returns> public override string Execute(Hero h, string[] text) { string _result = null; Enemy _target; CanCauseDamage _attacker = h as CanCauseDamage; if (text.Length == 3 || text.Length == 5) { if (text[1] != "enemy") { _result = "Invalid Attack Command!: Attack Enemy (X)"; } else { string _enemyName = text[2]; _target = FetchEnemy(h, _enemyName); if (_target != null && EnemyManager.Instance.AttackAble(_target)) { if (text.Length == 3) { _attacker = h as CanCauseDamage; } else if (text.Length == 5) { if (text[3] != "using") { _result = "Do you mean: Attack Enemy X 'using' W?"; } else { _attacker = FetchAttacker(h, text[4]); if (_attacker != null) { return(_result = AttackThisEnemy(_attacker, _target)); } _result = "Can't find the " + text[4] + "!"; } return(_result); } _result = AttackThisEnemy(_attacker, _target); } else { _result = "There is no enemy like that."; } } } else { _result = "Invalid Attack Command!: Attack Enemy (X) using (W)"; } return(_result); }
/// <summary> /// Hit the targetted enemy and return result of attack /// </summary> /// <param name="h">thing that cause damage</param> /// <param name="eneFound">targetted enemy</param> /// <returns>result of attack</returns> private string AttackThisEnemy(CanCauseDamage h, Enemy eneFound) { return(GameManager.Instance.AttackController(h, eneFound) + Environment.NewLine + eneFound.FullDescription); }