|
Britbot
|
00001 using Pirates; 00002 00003 namespace Britbot.Simulator 00004 { 00008 internal class GroupArrivalEvent : SimulatedEvent 00009 { 00010 #region Fields & Properies 00011 00015 private SimulatedGroup ArrivingGroup; 00016 00020 private SimulatedIsland Island; 00021 00022 #endregion 00023 00024 #region Constructors & Initializers 00025 00031 public GroupArrivalEvent(int turn, SimulatedIsland island, SimulatedGroup group) : base(turn) 00032 { 00033 this.Island = island; 00034 this.ArrivingGroup = group; 00035 } 00036 00037 #endregion 00038 00043 public override bool Activate(SimulatedGame sg) 00044 { 00045 if (this.ArrivingGroup.IsBusy) 00046 return false; 00047 00048 this.ArrivingGroup.IsBusy = true; 00049 00050 if (this.ArrivingGroup == null) 00051 return false; 00052 00053 if (!this.ArrivingGroup.IsAlive) 00054 return false; 00055 00056 if (this.Island.CapturingGroup != null) 00057 { 00058 if (this.Island.CapturingGroup.Owner == this.ArrivingGroup.Owner) 00059 return false; 00060 00061 //opponenets 00062 if (this.Island.CapturingGroup.IsAlive) 00063 { 00064 if (this.Island.CapturingGroup.ActualFirePower() > this.ArrivingGroup.FirePower) 00065 { 00066 this.ArrivingGroup.Kill(sg); 00067 return false; 00068 } 00069 if (this.Island.CapturingGroup.ActualFirePower() == this.ArrivingGroup.FirePower) 00070 { 00071 this.ArrivingGroup.Kill(sg); 00072 this.Island.CapturingGroup.Kill(sg); 00073 return false; 00074 } 00075 this.Island.CapturingGroup.Kill(sg); 00076 this.Island.TurnsBeingCaptured = 0; 00077 } 00078 } 00079 00080 this.Island.CapturingGroup = this.ArrivingGroup; 00081 00082 if (this.Island.Owner == this.ArrivingGroup.Owner) 00083 return false; 00084 if (this.Island.Owner == Consts.NO_OWNER) 00085 sg.AddEvent(new CaptureEvent(sg.CurrentTurn + 20 - this.Island.TurnsBeingCaptured, this.Island, 00086 this.ArrivingGroup)); 00087 else 00088 sg.AddEvent(new DeCaptureEvent(sg.CurrentTurn + 20 - this.Island.TurnsBeingCaptured, this.Island, 00089 this.ArrivingGroup)); 00090 00091 return false; 00092 } 00093 } 00094 }
1.7.6.1