Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void oneSecondReinforce_Step2(Coordinate location)
- {
- Hashtable hashtable = new Hashtable();
- hashtable["uid"] = PlayerData.inst.uid;
- hashtable["opp_uid"] = PVPMapData.MapData.GetReferenceAt(location).UserData.uid;
- MessageHub.inst.GetPortByAction("PVP:getReinforceList").SendRequest(hashtable, delegate (bool ret, object data1)
- {
- if (ret)
- {
- Hashtable hashtable1 = data1 as Hashtable;
- long totalTroop = 0;
- long totalCapacity = 0;
- if (hashtable1.ContainsKey("capacity_info"))
- {
- hashtable1 = (hashtable1["capacity_info"] as Hashtable);
- if (hashtable1 != null)
- {
- if (hashtable1.ContainsKey("troops_amount"))
- {
- totalTroop = (long)int.Parse(hashtable1["troops_amount"].ToString());
- }
- if (hashtable1.ContainsKey("capacity"))
- {
- totalCapacity = int.Parse(hashtable1["capacity"].ToString());
- }
- }
- }
- long remainCapacity = totalCapacity - totalTroop;
- BetterDebugMenu.m_Logs += "\n\nTarget City has " + remainCapacity + " capacity to reinforce";
- bool isDragonIn = false;
- if (PlayerData.inst.dragonData != null && PlayerData.inst.dragonData.MarchId == 0L && GameEngine.Instance.CurrentGameMode != GameEngine.GameMode.DragonKnight)
- {
- isDragonIn = true;
- }
- int maxTroopCount = (int)DBManager.inst.DB_Local_Benefit.Get("prop_march_capacity_base_value").total;
- maxTroopCount = (int)ConfigManager.inst.DB_BenefitCalc.GetFinalData((float)maxTroopCount, "calc_march_capacity", ConfigBenefitCalc.CalcOption.dragonAttack);
- if(maxTroopCount > remainCapacity)
- {
- maxTroopCount = (int)remainCapacity;
- }
- CityTroopsInfo cityTroops = PlayerData.inst.playerCityData.cityTroops;
- Hashtable troops = new Hashtable();
- int remain = maxTroopCount;
- foreach (var key in cityTroops.troops.Keys)
- {
- Unit_StatisticsInfo data = ConfigManager.inst.DB_Unit_Statistics.GetData(key);
- if (data == null || data.Type == "trap") continue;
- var troop = cityTroops.troops[key];
- int val = 0;
- if (key.Equals("infantry_t11"))
- {
- val = (int)Math.Min(troop, Math.Floor(maxTroopCount * 0.25));
- val = (int)Math.Min(val, remain);
- troops.Add(key, val);//25% or available count
- }
- else if (key.Equals("infantry_t10"))
- {
- val = (int)Math.Min(troop, Math.Floor(maxTroopCount * 0.03));
- val = (int)Math.Min(val, remain);
- troops.Add(key, val);//3% or available count
- }
- else if (key.Equals("ranged_t11"))
- {
- val = (int)Math.Min(troop, Math.Floor(maxTroopCount * 0.325));
- val = (int)Math.Min(val, remain);
- troops.Add(key, val);//32.5% or available count
- }
- else if (key.Equals("ranged_t10"))
- {
- val = (int)Math.Min(troop, Math.Floor(maxTroopCount * 0.08));
- val = (int)Math.Min(val, remain);
- troops.Add(key, val);//8% or available count
- }
- else if (key.Equals("ranged_t9"))
- {
- val = (int)Math.Min(troop, Math.Floor(maxTroopCount * 0.03));
- val = (int)Math.Min(val, remain);
- troops.Add(key, val);//3% or available count
- }
- else if (key.Equals("cavalry_t11"))
- {
- val = (int)Math.Min(troop, Math.Floor(maxTroopCount * 0.22));
- val = (int)Math.Min(val, remain);
- troops.Add(key, val);//22% or available count
- }
- else if (key.Equals("cavalry_t8"))
- {
- val = (int)Math.Min(troop, Math.Floor(maxTroopCount * 0.015));
- val = (int)Math.Min(val, remain);
- troops.Add(key, val);//1.5% or available count
- }
- else if (!key.Equals("cavalry_t10"))
- {
- val = Math.Min(1, troop);
- val = (int)Math.Min(val, remain);
- if (val > 0) troops.Add(key, val);//1 troop for all other troops
- }
- remain -= val;
- }
- if (cityTroops.troops.ContainsKey("cavalry_t10") && cityTroops.troops["cavalry_t10"] > 0)
- {
- troops.Add("cavalry_t10", Math.Min(cityTroops.troops["cavalry_t10"], remain)); // remaining for t10 cavalry
- }
- GameEngine.Instance.marchSystem.StartReinforce(location, troops, isDragonIn, new Action<bool, object>(OnStartMarchCallback));
- }
- }, true);
- }
Add Comment
Please, Sign In to add comment