public async Task Attack(int index = 0) { Player player; string log; if (IsPrivate(Context.Channel, out log)) { if (CheckPlayer(out player, out log) && IsInBattle(player)) { Battling task = player.task as Battling; Battle battle = BattleManager.Instance.GetBattle(task.battleId); if (index == 0) { index++; } if (IsValidIndex(index - 1, battle.monsters.Cast <Character>().ToList(), out log)) { Attack action = new Attack(player, battle.monsters[index - 1]); battle.AddAction(action); await BattleManager.Instance.PerformBattle(battle, Context.Channel); } } } if (log != "") { await ReplyAsync(log); } }
public Side(int Format, bool Opponent, bool Computer, params Pokemon[] Party) { if (Party == null || Party.Length == 0) { throw new ArgumentException("Party Empty", nameof(Party)); } if (Party.Length > 6) { throw new ArgumentOutOfRangeException(nameof(Party), "At most 6 Pokemon are allowed"); } if (Format > Party.Length) { throw new ArgumentException("Party size lesser than required for the format", nameof(Format)); } this.Format = Format; this.Opponent = Opponent; this.Computer = Computer; _party = Party; for (var i = 0; i < Format; ++i) { Battling.Add(Party[i]); } foreach (var pokemon in Party) { pokemon.Side = this; } }
public async Task RegisterBattle(Player player, IMessageChannel channel) { Battle battle = new Battle() { id = GenerateUniqueID(), players = new List <Player>() { player }, monsters = GenerateMonsters(player.level, player.field) }; if (battle.monsters != null && battle.monsters.Count > 0 && !battles.ContainsKey(battle.id)) { battles.Add(battle.id, battle); Battling task = new Battling(battle.id); player.SetTask(task); await channel.SendMessageAsync($"You are now in combat!"); await DisplayCharacters("Monsters", battle.monsters, channel); } else { await channel.SendMessageAsync($"You found no monsters to fight..."); } }
public async Task Cast(string skillName, int index) { Player player; string log; if (IsPrivate(Context.Channel, out log)) { if (CheckPlayer(out player, out log) && IsInBattle(player)) { Skill skill = GameData.Instance.GetSkill(skillName); if (skill != null) { if (player.HasSkill(skillName)) { if (player.currentStats.MP >= skill.mpCost) { Battling task = player.task as Battling; Battle battle = BattleManager.Instance.GetBattle(task.battleId); List <Character> characters = skill.isFriendly ? battle.players.Cast <Character>().ToList() : battle.monsters.Cast <Character>().ToList(); if (IsValidIndex(index - 1, characters, out log)) { Cast action; if (skill.isAoe) { action = new Cast(player, characters, skill); } else { action = new Cast(player, characters[index - 1], skill); } battle.AddAction(action); await BattleManager.Instance.PerformBattle(battle, Context.Channel); } } else { log = "Not enough mana..."; } } else { log = $"You have not learned {skillName}!"; } } else { log = "Unknown skill name..."; } } } if (log != "") { await ReplyAsync(log); } }
private bool CheckRun(Battling B) { if (B.Run && B.RunAttempt()) { this.Ended = true; return(true); } return(false); }
public bool TriedRun() { Battling B = list[turn]; if (B.Run) { return(true); } return(false); }
public async Task Use(string itemName, int index) { Player player; string log; if (IsPrivate(Context.Channel, out log)) { if (CheckPlayer(out player, out log) && IsInBattle(player)) { Battling task = player.task as Battling; Battle battle = BattleManager.Instance.GetBattle(task.battleId); Item item = GameData.Instance.GetItem(itemName); if (item != null && item is Consumable) { Consumable consumable = item as Consumable; List <Character> characters; if (consumable.friendly) { characters = battle.players.Cast <Character>().ToList(); } else { characters = battle.monsters.Cast <Character>().ToList(); } if (IsValidIndex(index - 1, characters, out log)) { Use action = new Use(consumable, player, characters[index - 1]); battle.AddAction(action); await BattleManager.Instance.PerformBattle(battle, Context.Channel); } } else { log = "Unknown consumable item..."; } } } if (log != "") { await ReplyAsync(log); } }
public async Task Flee() { Player player; string log; if (!IsPrivate(Context.Channel, out log)) { await ReplyAsync(log); return; } if (CheckPlayer(out player, out log) && IsInBattle(player)) { Battling task = player.task as Battling; Battle battle = BattleManager.Instance.GetBattle(task.battleId); Random random = new Random(); if (random.Next(0, 100) <= 50 + player.currentStats.EVA) { await ReplyAsync("You have successfully fled!"); BattleManager.Instance.RemoveBattle(battle.id); BattleManager.Instance.ResetPlayer(player); battle = null; task = null; } else { NoAction action = new NoAction(player); battle.AddAction(action); await BattleManager.Instance.PerformBattle(battle, Context.Channel); } } if (log != "") { await ReplyAsync(log); } }
public BattleManager(Creature a, Creature b) { string bda; string bdb; if (a.Ability > b.Ability) { bda = "easy"; bdb = "hard"; } else if (a.Ability < b.Ability) { bda = "hard"; bdb = "easy"; } else { bda = "normal"; bdb = "normal"; } this.b1 = new Battling(a, bda, true); this.b2 = new Battling(b, bdb, false); list = new List <Battling>(); if (RollIniciative(a) > RollIniciative(b)) { list.Add(b1); list.Add(b2); } else { list.Add(b2); list.Add(b1); } this.turn = 0; this.Ended = false; this._RunEnded = false; this.BL = new BattleLogger(); }