Skip to content
This repository has been archived by the owner on Oct 19, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1 from luiges90/master
Browse files Browse the repository at this point in the history
Merge pull request #1 from luiges90/master
  • Loading branch information
kpxp committed Nov 15, 2014
2 parents 6123030 + f18a748 commit d170571
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 38 deletions.
1 change: 1 addition & 0 deletions GameGlobal/GameGlobal/FrameFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public enum FrameFunction
GetBeMergedMilitaries,
GetBeDisbandedMilitaries,
GetLevelUpMilitaries,
GetLevelUpMiliaryKind,
GetNewCapital,
GetFriendlyDiplomaticRelation,
GetAllyDiplomaticRelation,
Expand Down
1 change: 1 addition & 0 deletions GameObjects/GameObjects.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,7 @@
<Compile Include="GameObjects\Conditions\ConditionKindPack\ConditionKind1540.cs" />
<Compile Include="GameObjects\Conditions\ConditionKindPack\ConditionKind1550.cs" />
<Compile Include="GameObjects\FoodPack.cs" />
<Compile Include="GameObjects\Influences\InfluenceKindPack\InfluenceKind330.cs" />
<Compile Include="GameObjects\Influences\InfluenceKindPack\InfluenceKind6160.cs" />
<Compile Include="GameObjects\Influences\InfluenceKindPack\InfluenceKind6165.cs" />
<Compile Include="GameObjects\Influences\InfluenceKindPack\InfluenceKind6170.cs" />
Expand Down
66 changes: 38 additions & 28 deletions GameObjects/GameObjects/Architecture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public int Compare(Troop x, Troop y)
private GameArea longViewArea = null;
public MilitaryList MergeMilitaryList = new MilitaryList();
public MilitaryList Militaries = new MilitaryList();
public MilitaryKindList UpgradableMilitaryKindList = new MilitaryKindList();
private int morale;
public int MoraleOfRecruitment = 50;
public float MultipleOfRecovery = 1;
Expand Down Expand Up @@ -2360,7 +2361,17 @@ private void AIMilitary()
{
foreach (Military military in this.GetLevelUpMilitaryList())
{
this.LevelUpMilitary(military);
List<MilitaryKind> candidates = military.Kind.GetLevelUpKinds();
List<MilitaryKind> upgradable = new List<MilitaryKind>();
foreach (MilitaryKind mk in candidates)
{
if (!this.BelongedFaction.IsMilitaryKindOverLimit(mk.ID))
{
upgradable.Add(mk);
}
}

this.LevelUpMilitary(military, upgradable[GameObject.Random(upgradable.Count)]);
}
}

Expand Down Expand Up @@ -6511,8 +6522,18 @@ public MilitaryList GetLevelUpMilitaryList()
this.LevelUpMilitaryList.Clear();
foreach (Military military in this.Militaries)
{
bool hasLevelupable = false;
foreach (int id in military.Kind.LevelUpKindID)
{
if (!this.BelongedFaction.IsMilitaryKindOverLimit(id))
{
hasLevelupable = true;
break;
}
}

if (((military.InjuryQuantity == 0) && military.Kind != null && military.Kind.CanLevelUp) && (military.Experience >= military.Kind.LevelUpExperience)
&& (!this.BelongedFaction.IsMilitaryKindOverLimit(military.Kind.LevelUpKindID)))
&& hasLevelupable)
{
military.BelongedFaction = this.BelongedFaction;
this.LevelUpMilitaryList.AddMilitary(military);
Expand Down Expand Up @@ -6549,6 +6570,19 @@ public GameArea GetMilitaryCampaignArea(Military military)
return allAvailableArea;
}

public MilitaryKindList GetUpgradableMilitaryKindList(Military m)
{
this.UpgradableMilitaryKindList.Clear();
foreach (MilitaryKind mk in m.Kind.GetLevelUpKinds())
{
if (!this.BelongedFaction.IsMilitaryKindOverLimit(mk.ID))
{
this.UpgradableMilitaryKindList.Add(mk);
}
}
return this.UpgradableMilitaryKindList;
}

public MilitaryKindList GetNewMilitaryKindList()
{
this.NewMilitaryKindList.Clear();
Expand Down Expand Up @@ -8028,20 +8062,11 @@ public bool IsWaterLink(Architecture a)

public bool LevelUpAvail()
{
foreach (Military military in this.Militaries)
{
if (((military.InjuryQuantity == 0) && military.Kind.CanLevelUp) && (military.Experience >= military.Kind.LevelUpExperience)
&& (!military.BelongedFaction.IsMilitaryKindOverLimit(military.Kind.LevelUpKindID)))
{
return true;
}
}
return false;
return GetLevelUpMilitaryList().Count > 0;
}

public void LevelUpMilitary(Military m)
public void LevelUpMilitary(Military m, MilitaryKind militaryKind)
{
MilitaryKind militaryKind = base.Scenario.GameCommonData.AllMilitaryKinds.GetMilitaryKind(m.Kind.LevelUpKindID);
if ((militaryKind != null) && (!m.BelongedFaction.IsMilitaryKindOverLimit(militaryKind.ID)))
{
int num = (m.Quantity * militaryKind.MinScale) / m.Kind.MinScale;
Expand Down Expand Up @@ -9488,21 +9513,6 @@ private bool CanRecruitLowerMilitary_r(MilitaryKind mk)
}
}
}
foreach (MilitaryKind i in base.Scenario.GameCommonData.AllMilitaryKinds.MilitaryKinds.Values)
{
if (i.LevelUpKindID == mk.ID)
{
crlm_recurse_level++;
if (crlm_recurse_level > 50)
{
return false;
}
if (CanRecruitLowerMilitary_r(i))
{
return true;
}
}
}
return false;
}

Expand Down
5 changes: 3 additions & 2 deletions GameObjects/GameObjects/CommonData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,8 @@ public List<string> LoadMilitaryKind(OleDbConnection connection, GameScenario sc
militaryKind.OffencePerScale = (short)reader["OffencePerScale"];
militaryKind.DefencePerScale = (short)reader["DefencePerScale"];
militaryKind.CanLevelUp = (bool)reader["CanLevelUp"];
militaryKind.LevelUpKindID = (short)reader["LevelUpKindID"];
StaticMethods.LoadFromString(militaryKind.LevelUpKindID, reader["LevelUpKindID"].ToString());
militaryKind.LevelUpKindID.RemoveAll(i => i == -1);
militaryKind.LevelUpExperience = (int)reader["LevelUpExperience"];
militaryKind.OffencePer100Experience = (short)reader["OffencePer100Experience"];
militaryKind.DefencePer100Experience = (short)reader["DefencePer100Experience"];
Expand Down Expand Up @@ -2102,7 +2103,7 @@ public void SaveAllToDatabase(string connectionString)
row["DefencePerScale"] = i.DefencePerScale;
row["MaxScale"] = i.MaxScale;
row["CanLevelUp"] = i.CanLevelUp;
row["LevelUpKindID"] = i.LevelUpKindID;
row["LevelUpKindID"] = StaticMethods.SaveToString(i.LevelUpKindID);
row["LevelUpExperience"] = i.LevelUpExperience;
row["OffencePer100Experience"] = i.OffencePer100Experience;
row["DefencePer100Experience"] = i.DefencePer100Experience;
Expand Down
3 changes: 3 additions & 0 deletions GameObjects/GameObjects/Influences/Influence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ public double AIPersonValue
case 320:
return this.Kind.AIPersonValue *
(base.Scenario.GameCommonData.AllCombatMethods.GetCombatMethod((int)p1).Combativity * this.Kind.AIPersonValuePow);
case 330:
return this.Kind.AIPersonValue *
(base.Scenario.GameCommonData.AllStunts.GetStunt((int)p1).Combativity * this.Kind.AIPersonValuePow);
case 860:
return this.Kind.AIPersonValue *
(base.Scenario.GameCommonData.AllStratagems.GetStratagem((int)p1).Combativity * this.Kind.AIPersonValuePow);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace GameObjects.Influences.InfluenceKindPack
{
using GameObjects;
using GameObjects.Influences;
using System;

internal class InfluenceKind330 : InfluenceKind
{
private int combatMethodID;

public override void ApplyInfluenceKind(Troop troop)
{
troop.Stunts.AddStunt(troop.Scenario.GameCommonData.AllStunts.GetStunt(this.combatMethodID));
}

public override void InitializeParameter(string parameter)
{
try
{
this.combatMethodID = int.Parse(parameter);
}
catch
{
}
}

public override void PurifyInfluenceKind(Troop troop)
{
troop.Stunts.RemoveStunt(troop.Scenario.GameCommonData.AllStunts.GetStunt(this.combatMethodID));
}
}
}

10 changes: 10 additions & 0 deletions GameObjects/GameObjects/PersonDetail/StuntTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ public bool AddStunt(Stunt stunt)
return true;
}

public bool RemoveStunt(Stunt stunt)
{
if (!this.Stunts.ContainsKey(stunt.ID))
{
return false;
}
this.Stunts.Remove(stunt.ID);
return true;
}

public void Clear()
{
this.Stunts.Clear();
Expand Down
16 changes: 13 additions & 3 deletions GameObjects/GameObjects/TroopDetail/MilitaryKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class MilitaryKind : GameObject
private int injuryChance;
private bool isShell;
private int levelUpExperience;
private int levelUpKindID;
private List<int> levelUpKindID = new List<int>();
private int marshAdaptability;
private float marshRate;
private int maxScale;
Expand Down Expand Up @@ -656,18 +656,28 @@ public int LevelUpExperience
}
}

public int LevelUpKindID
public List<int> LevelUpKindID
{
get
{
return this.levelUpKindID;
}
set
{
this.levelUpKindID = value;
this.levelUpKindID.RemoveAll(i => i == -1);
}
}

public List<MilitaryKind> GetLevelUpKinds()
{
List<MilitaryKind> result = new List<MilitaryKind>();
foreach (int id in LevelUpKindID)
{
result.Add(base.Scenario.GameCommonData.AllMilitaryKinds.GetMilitaryKind(id));
}
return result;
}

public int MarshAdaptability
{
get
Expand Down
2 changes: 1 addition & 1 deletion WorldOfTheThreeKingdoms/YouxiPingmu/MGSContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ private void HandleContextMenuResult(ContextMenuResult result)
break;

case ContextMenuResult.Military_LevelUp:
this.ShowTabListInFrame(UndoneWorkKind.Frame, FrameKind.Military, FrameFunction.GetLevelUpMilitaries, false, true, true, true, this.CurrentArchitecture.GetLevelUpMilitaryList(), null, "选择编队", "");
this.ShowTabListInFrame(UndoneWorkKind.Frame, FrameKind.Military, FrameFunction.GetLevelUpMilitaries, false, true, true, false, this.CurrentArchitecture.GetLevelUpMilitaryList(), null, "选择编队", "");
break;

case ContextMenuResult.Routeway_Design: //粮道手动设计
Expand Down
25 changes: 21 additions & 4 deletions WorldOfTheThreeKingdoms/YouxiPingmu/ScreenManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,27 @@ private void FrameFunction_Architecture_AfterGetInstigatePerson()
}
}

private void FrameFunction_Architecture_AfterGetLevelUpMilitaryKind()
{
if (this.CurrentArchitecture != null)
{
this.CurrentGameObjects = this.CurrentArchitecture.UpgradableMilitaryKindList.GetSelectedList();
if ((this.CurrentGameObjects != null) && (this.CurrentGameObjects.Count == 1))
{
this.CurrentArchitecture.CreateMilitary(this.CurrentGameObjects[0] as MilitaryKind);
}
}
}

private void FrameFunction_Architecture_AfterGetLevelUpMilitaries()
{
this.CurrentGameObjects = this.CurrentArchitecture.LevelUpMilitaryList.GetSelectedList();
if (this.CurrentGameObjects != null)
if (this.CurrentArchitecture != null)
{
foreach (Military military in this.CurrentGameObjects)
this.CurrentGameObjects = this.CurrentArchitecture.LevelUpMilitaryList.GetSelectedList();
if ((this.CurrentGameObjects != null) && (this.CurrentGameObjects.Count == 1))
{
this.CurrentArchitecture.LevelUpMilitary(military);
this.CurrentMilitary = (Military) this.CurrentGameObjects[0];
this.mainGameScreen.ShowTabListInFrame(UndoneWorkKind.Frame, FrameKind.MilitaryKind, FrameFunction.GetLevelUpMiliaryKind, true, false, true, false, this.CurrentArchitecture.GetUpgradableMilitaryKindList(this.CurrentMilitary), null, "编队升级", "编队升级");
}
}
}
Expand Down Expand Up @@ -928,6 +941,10 @@ public void HandleFrameFunction(FrameFunction function)
this.FrameFunction_Architecture_AfterGetLevelUpMilitaries();
break;

case FrameFunction.GetLevelUpMiliaryKind:
this.FrameFunction_Architecture_AfterGetLevelUpMilitaryKind();
break;

case FrameFunction.SelectMarryablePerson:
this.FrameFunction_Architecture_AfterSelectMarryablePerson();
break;
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit d170571

Please sign in to comment.