|
Britbot
|
00001 #region Usings 00002 00003 using Pirates; 00004 00005 #endregion 00006 00007 namespace Britbot.Simulator 00008 { 00009 class SimulatedIsland 00010 { 00011 #region Fields & Properies 00012 00013 public SimulatedGroup CapturingGroup; 00014 public int Owner; 00015 public int TurnsBeingCaptured; 00016 public int Id { get; set; } 00017 public int Value { get; set; } 00018 00019 //original data 00020 public int OriginalOwner; 00021 public int OriginalTrunsBeingCaptured; 00022 public SimulatedGroup OriginalCapturingGroup; 00023 00024 #endregion 00025 00034 public SimulatedIsland(int owner, int turnsBeingCaptured,int id,int value, SimulatedGroup capturingGroup = null) 00035 { 00036 this.Owner = owner; 00037 this.TurnsBeingCaptured = turnsBeingCaptured; 00038 this.Id = id; 00039 this.Value = value; 00040 this.CapturingGroup = capturingGroup; 00041 00042 //set original 00043 00044 this.OriginalCapturingGroup = capturingGroup; 00045 this.OriginalOwner = owner; 00046 this.OriginalTrunsBeingCaptured = turnsBeingCaptured; 00047 } 00048 00054 public int TurnsTillCapture(int capturer) 00055 { 00056 //calculate total number of turns to capture (without partials) 00057 int totalCaptureTime; 00058 //check if conqueror is the owner 00059 if (this.Owner == capturer) 00060 { 00061 totalCaptureTime = 0; 00062 } //if the isalnd is nutral 00063 else if (this.Owner == Consts.NO_OWNER) 00064 { 00065 totalCaptureTime = this.TurnsBeingCaptured; 00066 } //if the island is of the other team 00067 else 00068 { 00069 totalCaptureTime = 2 * this.TurnsBeingCaptured; 00070 } 00071 00072 //check if we already have some capture time 00073 if (this.CapturingGroup.Owner == capturer) 00074 { 00075 return totalCaptureTime - this.TurnsBeingCaptured; 00076 } 00077 return totalCaptureTime; 00078 } 00079 00085 public int TurnsTillDecapture(int capturer) 00086 { 00087 //calculate total number of turns to capture (without partials) 00088 int totalCaptureTime; 00089 //check if conqueror is the owner 00090 if (this.Owner == capturer) 00091 { 00092 return 0; 00093 } //if the isalnd is nutral 00094 else if (this.Owner == Consts.NO_OWNER) 00095 { 00096 totalCaptureTime = 0; 00097 } //if the island is of the other team 00098 else 00099 { 00100 totalCaptureTime = this.TurnsBeingCaptured; 00101 } 00102 00103 //check if we already have some capture time 00104 if (this.CapturingGroup.Owner == capturer) 00105 { 00106 return totalCaptureTime - this.TurnsBeingCaptured; 00107 } 00108 return totalCaptureTime; 00109 } 00110 00115 public void KillLocals(SimulatedGame sg) 00116 { 00117 if (this.CapturingGroup != null) 00118 { 00119 this.CapturingGroup.Kill(sg); 00120 00121 //update turn counter 00122 this.TurnsBeingCaptured = 0; 00123 } 00124 } 00125 00130 public void Update(int turnDiff) 00131 { 00132 this.TurnsBeingCaptured += turnDiff; 00133 } 00134 } 00135 }
1.7.6.1