Skip to content

Commit

Permalink
加入纳妾功能
Browse files Browse the repository at this point in the history
  • Loading branch information
k2lizheng authored and luiges90 committed Oct 19, 2023
1 parent d598941 commit 223a2a3
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 2 deletions.
1 change: 1 addition & 0 deletions Content/Data/Plugins/ContextMenuData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
<MenuItem ID="5" Name="MoveCaptive" DisplayName="转移俘虏" DisplayIfTrue="MoveCaptiveAvail" />
</MenuItem>
<MenuItem ID="9" Name="MakeMarriage" DisplayName="赐婚" DisplayIfTrue="HasMarriageToMake"/>
<MenuItem ID="11" Name="MakeMarriage2" DisplayName="纳妾" DisplayIfTrue="HasMarriageToMake2"/>
<MenuItem ID="6" Name="hougongTop" DisplayName="后宫">
<MenuItem ID="1" Name="nafei" DisplayName="纳妃" DisplayIfTrue="kenafei" />
<MenuItem ID="2" Name="hougong" DisplayName="宠幸" DisplayIfTrue="kejinhougong" />
Expand Down
1 change: 1 addition & 0 deletions WorldOfTheThreeKingdoms/GameGlobal/ContextMenuResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public enum ContextMenuResult
Monarch_ZhaoXianBang_DismissOfficer, //遣散
Monarch_Techniques,
Monarch_MakeMarriage,
Monarch_MakeMarriage2,//纳妾
Monarch_TrainChildren,
Monarch_KillRelease_ReleaseSelfPerson,
Monarch_KillRelease_MoveCaptive, //转移俘虏
Expand Down
1 change: 1 addition & 0 deletions WorldOfTheThreeKingdoms/GameGlobal/FrameFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public enum FrameFunction
SelectLandLink,
SelectWaterLink,
SelectMarryablePerson,
SelectMarryablePerson2,//妾
SelectMarryTo,
SelectTrainableChildren,
SelectTrainPolicy,
Expand Down
20 changes: 20 additions & 0 deletions WorldOfTheThreeKingdoms/GameObjects/Architecture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9463,6 +9463,11 @@ public bool HasMarriageToMake()
return this.makeMarryablePersons().Count > 0;
}

public bool HasMarriageToMake2()
{
return this.MakeMarryablePersons2().Count > 0;
}

public bool HasChildrenToTrain()
{
return this.BelongedFaction.Leader.TrainableChildren.Count > 0;
Expand Down Expand Up @@ -12858,6 +12863,21 @@ public PersonList makeMarryablePersons()
return result;
}

public PersonList MakeMarryablePersons2()//可以纳妾的男武将列表
{
PersonList result = new PersonList();

if (this.Fund < Session.Parameters.MakeMarriageCost) return result;

foreach (Person p in this.Persons)
{
if (!p.Sex && p.MakeMarryable2().Count > 0)
{
result.Add(p);
}
}
return result;
}
public int AbundantFood
{
get
Expand Down
23 changes: 21 additions & 2 deletions WorldOfTheThreeKingdoms/GameObjects/Person.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2378,6 +2378,23 @@ public PersonList MakeMarryable()
return result;
}

public PersonList MakeMarryable2()//找妾
{
PersonList result = new PersonList();

if (this.LocationArchitecture == null) return result;

foreach (Person p in this.LocationArchitecture.Persons)
{
if (p.Sex && p.Spouse == null && Person.GetIdealOffset(p, this) <= Session.Parameters.MakeMarrigeIdealLimit)
{
result.Add(p);
}
}

return result;
}

public String MakeMarryableList
{
get
Expand Down Expand Up @@ -2442,8 +2459,10 @@ public void Marry(Person p, Person maker)

makeHateCausedByAffair(this, p, maker);
}

this.Spouse = p;
if (this.Spouse == null)
{
this.Spouse = p;
}
p.Spouse = this;

this.AdjustRelation(p, 25f, -5);
Expand Down
4 changes: 4 additions & 0 deletions WorldOfTheThreeKingdoms/GameScreens/MGSContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,10 @@ private void HandleContextMenuResult(ContextMenuResult result)
this.ShowTabListInFrame(UndoneWorkKind.Frame, FrameKind.Person, FrameFunction.SelectMarryablePerson, false, true, true, false, this.CurrentArchitecture.makeMarryablePersons(), null, "赐婚", "");
break;

case ContextMenuResult.Monarch_MakeMarriage2:
this.ShowTabListInFrame(UndoneWorkKind.Frame, FrameKind.Person, FrameFunction.SelectMarryablePerson2, false, true, true, false, this.CurrentArchitecture.MakeMarryablePersons2(), null, "纳妾", "");
break;

case ContextMenuResult.Monarch_TrainChildren:
this.ShowTabListInFrame(UndoneWorkKind.Frame, FrameKind.Person, FrameFunction.SelectTrainableChildren, false, true, true, true, this.CurrentArchitecture.BelongedFaction.Leader.TrainableChildren, null, "子女培育", "");
break;
Expand Down
13 changes: 13 additions & 0 deletions WorldOfTheThreeKingdoms/GameScreens/ScreenManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ private void FrameFunction_Architecture_AfterSelectMarryablePerson()
}
}

private void FrameFunction_Architecture_AfterSelectMarryablePerson2()
{
GameObjectList selectedList = this.CurrentArchitecture.Persons.GetSelectedList();
if ((selectedList != null) && (selectedList.Count == 1))
{
this.CurrentPerson = selectedList[0] as Person;
Session.MainGame.mainGameScreen.ShowTabListInFrame(UndoneWorkKind.Frame, FrameKind.Person, FrameFunction.SelectMarryTo, false, true, true, false, this.CurrentPerson.MakeMarryable2(), null, "选择纳妾对象", "");
}
}
private void FrameFunction_Architecture_AfterSelectMarryTo()
{
GameObjectList selectedList = this.CurrentArchitecture.Persons.GetSelectedList();
Expand Down Expand Up @@ -1258,6 +1267,10 @@ public void HandleFrameFunction(FrameFunction function)
this.FrameFunction_Architecture_AfterSelectMarryablePerson();
break;

case FrameFunction.SelectMarryablePerson2:
this.FrameFunction_Architecture_AfterSelectMarryablePerson2();
break;

case FrameFunction.SelectMarryTo:
this.FrameFunction_Architecture_AfterSelectMarryTo();
break;
Expand Down

0 comments on commit 223a2a3

Please sign in to comment.