public List <IInteractionable> finalize(IInteractionable requester, IInteractionable receiver) { requester.SetMustUpdate(true); return(new List <IInteractionable> { requester, receiver }); }
public List <IInteractionable> finalize(IInteractionable requester, IInteractionable receiver) { requester.GetRecursos().ForEach((rec) => { rec.SetAmount(0); }); requester.SetMustUpdate(true); return(new List <IInteractionable> { requester, receiver }); }
public List <IInteractionable> exec(IInteractionable requester, IInteractionable receiver) { receiver.Clean(); receiver.SetRecursos(requester.GetRecursos()); receiver.SetMustUpdate(true); requester.Return(); return(new List <IInteractionable> { requester, receiver }); }
public List <IInteractionable> exec(IInteractionable requester, IInteractionable receiver) { receiver.GetFlota().ForEach((c) => { destacamento.Add(c.GetId(), c.GetAmount()); }); receiver.GetDefensas().ForEach((c) => { destacamento.Add(c.GetId(), c.GetAmount()); }); receiver.GetRecursos().ForEach((c) => { recurso.Add(c.GetId(), c.GetAmount()); }); bool requesterWin = FlotaAmount(receiver) == 0; float round = 0; while (!requesterWin && FlotaAmount(requester) > 0) { System.Diagnostics.Debug.WriteLine("####Round" + round); round++; float receiverDice = GetInitiative(receiver); float requesterDice = GetInitiative(requester); //restore shield FlotaAtacadaReceiver.ForEach((u) => { u.RestoreShield(); }); FlotaAtacadaRequester.ForEach((u) => { u.RestoreShield(); }); var FlotaRapidaRequester = requester.GetFlota().OrderBy(c => c.GetVelocidad() * c.GetAmount()).Where(c => c.GetAmount() != 0); var FlotaRapidaReceiver = receiver.GetFlota().Concat(receiver.GetDefensas()).OrderBy(c => c.GetVelocidad() * c.GetAmount()).Where(c => c.GetAmount() != 0);; if (requesterDice >= receiverDice) { FlotaRapidaRequester.ToList().ForEach((c) => { PerformAttack(c, receiver, false); }); FlotaRapidaReceiver.ToList().ForEach((c) => { PerformAttack(c, requester, true); }); } else { FlotaRapidaReceiver.ToList().ForEach((c) => { PerformAttack(c, requester, true); }); FlotaRapidaRequester.ToList().ForEach((c) => { PerformAttack(c, receiver, false); }); } requesterWin = FlotaAmount(receiver) == 0; } if (requesterWin) { requester.Win(); requester.GetFlota().ForEach((des) => { var capacidad = des.GetCapacidad() / receiver.GetRecursos().Count; receiver.GetRecursos().ForEach((rec) => { var setter = requester.GetRecursos().Where(c => c.GetId() == rec.GetId()).FirstOrDefault(); if (setter == null) { return; } if (rec.GetAmount() < capacidad) { setter.SetAmount(setter.GetAmount() + rec.GetAmount()); rec.SetAmount(0); } else { setter.SetAmount(setter.GetAmount() + capacidad); rec.SetAmount(rec.GetAmount() - capacidad); } }); }); requester.Return(); } else { receiver.Win(); } destacamento.ToList().ForEach((r) => { IDestacamento defensa = receiver.GetDefensas().Where(c => c.GetId() == r.Key).FirstOrDefault(); if (defensa != null) { defensa.SetAmount(defensa.GetAmount() - r.Value); } }); destacamento.ToList().ForEach((r) => { IDestacamento flota = receiver.GetFlota().Where(c => c.GetId() == r.Key).FirstOrDefault(); if (flota != null) { flota.SetAmount(flota.GetAmount() - r.Value); } }); recurso.ToList().ForEach((r) => { IResources rec = receiver.GetRecursos().Where(c => c.GetId() == r.Key).FirstOrDefault(); if (rec != null) { rec.SetAmount(rec.GetAmount() - r.Value); } }); receiver.SetMustUpdate(true); return(new List <IInteractionable> { requester, receiver }); }