/// <summary> /// Get random fighting scene /// </summary> /// <returns></returns> public static string Fighting() { int text = WarMath.ResultPower(5); switch (text) { case 0: return("Le fracas des épées se fait entendre.\n"); case 1: return("La terre frémit sous le pied de attaquants.\n"); case 2: return("Les généraux chargent sans merci.\n"); case 3: return("Une volée de flèche siffle dans l'air.\n"); case 4: return("La première ligne défensive est percée.\n"); default: return("L'ardeur des combattants résonne dans l'air.\n"); } }
/// <summary> /// Compute the implication /// </summary> /// <param name="nbArmy"></param> /// <param name="attack"></param> public Implication(int nbArmy, float attack) { ArmyTotal = nbArmy; Army = WarMath.ResultPower(nbArmy, true); AttackPercent = attack; Attack = (int)(ArmyTotal * AttackPercent); ArmyBonus = Army + Attack; }
/// <summary> /// Phase 6 of the skirmish /// Hostage phase /// </summary> public void Phase6() { int l; int w; if (_totalForceBonus[0] == _totalForceBonus[1]) { return; } else if (_totalForceBonus[0] < _totalForceBonus[1]) { l = 0; w = 1; } else { l = 1; w = 0; } // Step 1, Add-On usable to boost Moral //Add-On available if (_addon[l] != null) { foreach (AddOn a in _addon[l]) { Console.WriteLine("Can use it? " + a.CanUseMorale()); if (a.CanUseMorale()) { bool useit = false; int i = 0; Console.WriteLine("Recover 0 " + _generalBest[l][0].IsRecoverable()); if (_generalBest[l][0].IsRecoverable()) { useit = true; i = 0; } else if (_generalBest[l].Count > 1 && _generalBest[l][0].IsRecoverable()) { useit = true; i = 1; } if (useit) { bool revive = _generalBest[l][i].IsRevive(a.Stat.Moral); if (revive) { _technical += "L'aide " + a.Name + " donne un boost de morale à " + _generalBest[l][i].Name + ", le groupe revient sur le champ de bataille.\n"; _detailed += "Incroyable! " + "L'aide" + a.Name + " donne un boost de morale à " + _generalBest[l][i].Name + ", le groupe revient sur le champ de bataille.\n"; } else { _technical += "L'aide " + a.Name + " n'est pas suffisante pour le morale.\n"; } a.UsedAddOn(); break; } } } } // Step 2, Decision making is defeated but by moral. bool[] moraleAction = { false, false }; if (_generalBest[l][0].CanHostage()) { moraleAction[0] = true; } if (_generalBest[l].Count > 1 && _generalBest[l][0].CanHostage()) { moraleAction[1] = true; } if (moraleAction[0] || moraleAction[1]) { _technical += "Il y a des otages.\n"; _detailed += "Hô non, il y a des otages!"; int massacre = 0; int mercy = 0; int hostage = 0; foreach (General g in _general[w]) { if (g.IsValid()) { int nego = WarMath.ResultPower(100 + (int)(100 * g.Stat.NegoPower), true); switch (g.Stat.Behaviour) { case Config.EndBehaviour.None: case Config.EndBehaviour.Mercy: mercy += nego; break; case Config.EndBehaviour.Carnage: massacre += nego; break; case Config.EndBehaviour.Hostage: hostage += nego; break; } } } _technical += "Décision sur les fuyards: \n"; _technical += Config.EnumToString(Config.EndBehaviour.Mercy) + ": " + mercy + "\n"; _technical += Config.EnumToString(Config.EndBehaviour.Carnage) + ": " + massacre + "\n"; _technical += Config.EnumToString(Config.EndBehaviour.Hostage) + ": " + hostage + "\n"; // Sorting Config.EndBehaviour decision; if (mercy > massacre) { if (hostage > mercy) { decision = Config.EndBehaviour.Hostage; } else { decision = Config.EndBehaviour.Mercy; } } else { if (hostage > massacre) { decision = Config.EndBehaviour.Hostage; } else { decision = Config.EndBehaviour.Carnage; } } _technical += "Décision final: " + Config.EnumToString(decision); _detailed += "Le conseil de guerre a décidé, la décision sur les otages est: " + Config.EnumToString(decision); for (int i = 0; i < 2; i++) { // Impact on both general if (moraleAction[i]) { if (decision == Config.EndBehaviour.Carnage && decision == Config.EndBehaviour.Hostage) { // Last resort! Check on aid to help escape! if (_addon[l] != null) { foreach (AddOn a in _addon[l]) { if (a.CanUseEscape()) { bool escape = WarMath.ResultChance(a.Stat.Escape); if (escape) { _technical += "Le général " + _generalBest[l][i].Name + " s'enfuit grâce à " + a.Name + "\n"; _detailed += "Le général " + _generalBest[l][i].Name + " utilise son dernier atout, " + a.Name + ", et s'enfuit.\n"; moraleAction[i] = false; continue; } else { _technical += "Aide de " + a.Name + " insuffisante pour " + _generalBest[l][i].Name + "\n"; } } } } _technical += "Le groupe du général " + _generalBest[l][i].Name + "\n"; _detailed += "Le groupe du général " + _generalBest[l][i].Name + "\n"; if (decision == Config.EndBehaviour.Hostage) { _technical += " est prit en otage\n"; _detailed += " est prit en otage\n"; } if (decision == Config.EndBehaviour.Carnage) { _technical += " se fait massacrer\n"; _detailed += " se fait massacrer\n"; } if (_generalBest[l][i].GeneralDead) { _technical += "Le général " + _generalBest[l][i].Name + " est"; _detailed += "Le général " + _generalBest[l][i].Name + " est"; } if (decision == Config.EndBehaviour.Hostage) { _technical += " prit en otage\n"; _detailed += " prit en otage\n"; } if (decision == Config.EndBehaviour.Carnage) { _technical += " massacré\n"; _detailed += " massacré\n"; } } else { _technical += "\nLes fuyards ont quitter le champ de bataille."; _detailed += "\nLes fuyards ont quitter le champ de bataille."; } // Mercy and nothing is normal } } } //Delete defeated general for (int j = 0; j < SIDE; j++) { for (int i = _general[j].Count - 1; i >= 0; i--) { if (_general[j][i].Defeated) { _general[j].RemoveAt(i); } } } //Checkout the battle output int adverse = 1; for (int i = 0; i < SIDE; i++) { bool sideLose = true; foreach (General g in _general[i]) { if (!g.Saboteur) { sideLose = false; break; } } if (sideLose) { _technical += "\n\nLa bataille est fini " + _sides[i] + " est perdant.\n"; _technical += _sides[adverse] + " a gagné la bataille de " + _battleName; _detailed += "La bataille est fini! " + _sides[i] + " a perdu la bataille de " + _battleName + "\n"; _detailed += _sides[adverse] + " est victorieux!!\n"; Final = true; return; } adverse = 0; } }
/// <summary> /// Phase 2 of the skirmish /// Calculate the AddOn implication. /// First step if the base one. /// Second step is a counter and a counter's counter if possible. /// Please note that add-on can be negative, you cannot control them. /// </summary> public void Phase2() { // Phase 2 // Add-on essentials // Normal _technical += "Implication des aide extérieures OBLIGATOIRE dans la bataille: \n"; for (int i = 0; i < SIDE; i++) { bool hasOne = false; _technical += "Côté " + _sides[i] + "\n"; if (_addon[i] != null) { foreach (AddOn a in _addon[i]) { if (a.IsOrder() && a.IsOrderWhen(_time)) { int imp = a.GetCombatImplication(_totalForce[i]); _add[i] += imp; _technical += a.Name + ": " + imp + "\n"; if (imp > 0) { if (!hasOne) { _detailed += "Les tactiques " + _sides[i] + " commencent!\n"; _detailed += "Du côté " + _sides[i] + ", nous avons: "; hasOne = true; } _detailed += a.Name + "; "; } } } } _detailed += "\n"; } _technical += "Résultat de l'escarmouche sans ajout: \n"; for (int i = 0; i < SIDE; i++) { _totalForceBonus[i] = _force[i] + _add[i]; _technical += "Côté " + _sides[i] + ": " + _totalForceBonus[i] + "\n"; } // Phase 2 continues, add another round of reéquilibration int[] order = { 0, 1 }; _detailed += Flavor.Fighting(); // Normally, if 1 is greater than 0, 1 can have another shot. // If 0 is greater than 1, than 1 has the rights. if (_totalForceBonus[0] > _totalForceBonus[1]) { _detailed += "L'armée " + _sides[1] + " est en mauvaise posture...\n"; order[0] = 1; order[1] = 0; } else if (_totalForceBonus[0] == _totalForceBonus[1]) { _detailed += "La situation est tendue, chaque côté maintient son bout de terrain!\n"; // For tie, get 50% to get advantage float rand = WarMath.ResultPower(10); if (rand < 5) { order[0] = 0; order[1] = 1; } else { order[0] = 1; order[1] = 0; } } else { _detailed += "L'armée " + _sides[0] + " est en mauvaise posture...\n"; } // The weakest attack first as a reply if he can!! if (_addon[order[0]] != null) { foreach (AddOn a in _addon[order[0]]) { if (a.CanUseAttack()) { int imp = a.GetCombatImplication(_totalForce[order[0]]); _counterAdd[order[0]] = imp; _technical += "Côté " + _sides[order[0]] + " contre attaque avec " + a.Name + ": " + imp + "\n"; _detailed += "Mais attention! Le groupe " + _sides[order[0]] + " contre attaque avec " + a.Name + "\n"; } } _detailed += "Est-ce que ce sera suffisant?\n"; } // If the help is useful, we can counter attack the counter attack if (_counterAdd[order[0]] > 0) { // Fight back if (_addon[order[1]] != null) { foreach (AddOn a in _addon[order[1]]) { if (a.CanUseAttack()) { int imp = a.GetCombatImplication(_totalForce[order[1]]); _counterAdd[order[1]] = imp; _technical += "Côté " + _sides[order[1]] + " contre attaque la contre attaque avec " + a.Name + ": " + imp + "\n"; _detailed += "Attention, le groupe " + _sides[order[1]] + " n'en a pas fini! Une contre attaque avec " + a.Name + "\n"; } } } } _technical += "Résultat de l'escarmouche AVEC ajout: \n"; for (int i = 0; i < SIDE; i++) { _totalForceBonus[i] = _force[i] + _add[i] + _counterAdd[i]; _technical += "Côté " + _sides[i] + ": " + _totalForceBonus[i] + "\n"; } _technical += "\n"; }