public static Result Simulate(Guild guild, int totalTurnDuringBattring, Sinma.Base firstSinma, Sinma.Base secondSinma) { for (var turn = 0; turn < totalTurnDuringBattring; ++turn) { Sinma.Base sinma; if (!firstSinma.DidGone) { sinma = firstSinma; } else if (!secondSinma.DidGone) { sinma = secondSinma; } else { sinma = null; } var records = guild.Act(turn, sinma); sinma?.PassTurn(); } var result = new Result( firstRequiredTurnCount: firstSinma.TurnCountToSummon, secondRequiredTurnCount: secondSinma.TurnCountToSummon, records: guild.Records ); return(result); }
static Buki SelectPreferredBuki(Slot slot, Sinma.Base sinma) { var candidates = slot.Bukis .Where(sinma.DoesPrefer) .ToArray(); if (!candidates.Any()) { candidates = slot.Bukis; } var index = Environment.RandomRange(0, candidates.Length); return(candidates[index]); }
public List <Record> Act(int id, Sinma.Base sinma) { if (sinma != null && sinma.SinmaState == SinmaState.NoSign) { _remainTurnToCompletePrepare = Constant.TurnToCompletePrepare; } if (sinma != null && sinma.SinmaState == SinmaState.Signed) { _remainTurnToCompletePrepare--; } var sinmaCountDown = sinma != null && sinma.SinmaState == SinmaState.Signed ? _remainTurnToCompletePrepare : null; var records = new List <Record>(); foreach (var member in Members) { var buki = member.Act(sinmaCountDown, sinma); if (buki == null) { continue; } var record = new Record( id: id, actor: member.Name, sinmaState: sinma?.SinmaState ?? SinmaState.NoSign, isStrong: Environment.DoesJobStrongWith(member.Job, buki), didSinmaPrefer: sinma?.DoesPrefer(buki) ?? false ); sinma?.Watch(buki); records.Add(record); } _records.AddRange(records); return(records); }
public Buki Act(int?sinmaCountDown, Sinma.Base sinma) { var slot = Deck.Open(); if (!slot.Bukis.Any()) { Deck.Reset(); return(null); } Buki buki; switch (sinma?.SinmaState) { case SinmaState.NoSign: buki = SelectUnPreferredBuki(slot, sinma); break; case SinmaState.Signed: buki = SelectUnPreferredBuki(slot, sinma); break; case SinmaState.Summoning: buki = SelectPreferredBuki(slot, sinma); break; case SinmaState.Blessed: buki = SelectPreferredBuki(slot, sinma); break; case null: buki = SelectRandomBuki(slot); break; default: buki = SelectRandomBuki(slot); break; } Deck.ConsumeBuki(buki); return(buki); }