Skip to content

Commit

Permalink
Support for mixed-heritage in lifepath creator
Browse files Browse the repository at this point in the history
  • Loading branch information
qkmaxware committed May 27, 2021
1 parent be79af6 commit 9e83039
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 12 deletions.
5 changes: 5 additions & 0 deletions TrekSharp.AdventureTools/Pages/CreateMini.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@

<div class="no-print">
<LCARS Title="MINI">
<div class="w3-padding">
<button onclick="history.back()">
&lt; Back
</button>
</div>
<div class="w3-row">
<div class="w3-half">
<div class="w3-bar-block">
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/ViewCharacterSheet.razor
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</div>
<div class="w3-row">
<div class="w3-quarter text-secondary typeface">SPECIES:</div>
<div class="w3-threequarter w3-border-bottom">@Player.Species</div>
<div class="w3-threequarter w3-border-bottom">@Player.Species.ToFullString()</div>
</div>
<div class="w3-row">
<div class="w3-quarter text-secondary typeface">ASSIGNMENT:</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</div>
<div class="w3-row">
<div class="w3-quarter text-secondary typeface">SPECIES:</div>
<div class="w3-threequarter w3-border-bottom">@Player.Species</div>
<div class="w3-threequarter w3-border-bottom">@Player.Species.ToFullString()</div>
</div>
</div>
</div>
Expand Down
40 changes: 32 additions & 8 deletions TrekSharp.AdventureTools/Shared/LifepathWizard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@
</ListSelect>
</Content>
</WizardStage>
<WizardStage>
<Content>
<p>
Many characters have parents from different species. Mixed-heritage species are treated as a member of the primary species taking more features from one parent than from the other, but inherits the traits of and can choose the talents avaliable for the other species. This step is optional as you may choose to <b>not</b> have a character be of mixed-heritage.
</p>
<div class="w3-center w3-padding">
<button @onclick=toggleMixedHeritage>@(useMixed ? "Do Not Use" : "Use") Mixed Heritage</button>
</div>
@if (useMixed) {
<ListSelect @ref="speciesSecondarySelector" Title="MIXED HERITAGE" List=species Filterable=true OnSelectionChanged=StateHasChanged></ListSelect>
}
</Content>
</WizardStage>
<WizardStage>
<Content>
<div class="row">
Expand All @@ -79,7 +92,7 @@
</div>
<div class="hbar row-fill elbow-right knee-right" style="text-align: right;"></div>
</div>
@if (characterSpecies.AttributeModifiers == null) {
@if (characterPrimarySpecies.AttributeModifiers == null) {
<p>
This species has no default attributes, choose 3 attributes to increase.
</p>
Expand All @@ -93,7 +106,7 @@
<p>
This species has the following default attributes
</p>
foreach (var attr in characterSpecies.AttributeModifiers.Enumerate()) {
foreach (var attr in characterPrimarySpecies.AttributeModifiers.Enumerate()) {
<div class="row w3-margin-bottom">
<div class="hbar elbow-left knee-left secondary" style="width: 16px;"></div>
<div class="hbar w3-padding typeface secondary" style="width: 112px;">
Expand Down Expand Up @@ -148,7 +161,7 @@
<div class="w3-container">
@context.Description
</div>
@if ((context.AttributeSelectionMask ?? characterSpecies.AttributeModifiers ?? characterCustomSpeciesAttributes) != null) {
@if ((context.AttributeSelectionMask ?? characterPrimarySpecies.AttributeModifiers ?? characterCustomSpeciesAttributes) != null) {
<div class="row">
<div class="hbar elbow-left knee-left" style="width: 32px;"></div>
<div class="typeface" style="margin-left: 10px; margin-right: 10px;">
Expand All @@ -157,7 +170,7 @@
<div class="hbar row-fill elbow-right knee-right" style="text-align: right;"></div>
</div>
<div class="w3-container">
@foreach (var item in (context.AttributeSelectionMask ?? characterSpecies.AttributeModifiers ?? characterCustomSpeciesAttributes).Enumerate()){
@foreach (var item in (context.AttributeSelectionMask ?? characterPrimarySpecies.AttributeModifiers ?? characterCustomSpeciesAttributes).Enumerate()){
if (item.Value > 0) {
<div>@item.Name</div>
}
Expand Down Expand Up @@ -207,7 +220,7 @@
<div class="w3-container w3-padding">
<AttributeIncrement
Points="1"
Mask="characterEnvironment.AttributeSelectionMask ?? characterSpecies.AttributeModifiers ?? characterCustomSpeciesAttributes"
Mask="characterEnvironment.AttributeSelectionMask ?? characterPrimarySpecies.AttributeModifiers ?? characterCustomSpeciesAttributes"
Reference="characterEnvironmentAttributes"
/>
</div>
Expand Down Expand Up @@ -877,7 +890,7 @@
private Attributes characterBaseAttributes = new Attributes (7);
private Disciplines characterBaseDisciplines = new Disciplines (1);
private Attributes characterCustomSpeciesAttributes = new Attributes(0);
private Attributes speciesAttributes => characterSpecies?.AttributeModifiers ?? characterCustomSpeciesAttributes;
private Attributes speciesAttributes => characterPrimarySpecies?.AttributeModifiers ?? characterCustomSpeciesAttributes;

private Attributes characterCareerPathAttributes = new Attributes();
private Disciplines characterCareerPathMajorDisciplines = new Disciplines();
Expand Down Expand Up @@ -925,7 +938,8 @@
Name = characterName,
Rank = characterRank,
Assignment = characterAssignment,
Species = characterSpecies,
// Produces a "pure" species if characterSubspecies is null or empty
Species = characterPrimarySpecies.DeriveMixedSpecies(characterSubspecies),
Attributes = characterAttributesAfterRebalance,
Disciplines = characterDisciplinesAfterRebalance,
Equipment = characterEquipment,
Expand All @@ -942,8 +956,18 @@

#region Species
private ListSelect<Species> speciesSelector;
private Species characterSpecies => speciesSelector?.Selected;
private Species characterPrimarySpecies => speciesSelector?.Selected;
private bool requireSpecies() => speciesSelector?.Selected != null;

private bool useMixed;
private ListSelect<Species> speciesSecondarySelector;
private List<Species> characterSubspecies => speciesSecondarySelector.AllSelected;
private void toggleMixedHeritage() {
useMixed = !useMixed;
if (!useMixed) {
speciesSecondarySelector?.DeselectAll();
}
}
#endregion

#region First Talent
Expand Down
6 changes: 6 additions & 0 deletions TrekSharp.AdventureTools/Shared/ListSelect.razor
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,10 @@
}
OnSelectionChanged?.Invoke();
}

public void DeselectAll() {
this.AllSelected.Clear();
OnSelectionChanged?.Invoke();
StateHasChanged();
}
}
2 changes: 1 addition & 1 deletion TrekSharp/src/Rulebooks/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ List<Item> items
new SpeciesRestrictedTalent("Andorian", "Proud and Honorable", "Your personal integrity is unimpeachable, and you will not willingly break a promise made. Whenever you attempt a Task to resist being coerced into breaking a promise, betraying your allies, or otherwise acting dishonorably, you redice the Difficulty by 1."),
new SpeciesRestrictedTalent("Andorian", "The Ushaan", "You are experienced in the tradition of honor-dueling known as the Ushaan, having spilt much blood upon the ice. When you make a melee Attack, or are targeted by a melee Attack, and buy one or more d20s by adding to the Threat, you may re-roll the dice pool for the Task. Further, you own an Ushaan-tor mining tool traditionally used on these duels."),
new SpeciesRestrictedTalent("Bajoran", "Orb Experience", "You have received a vision from the Bajoran Prophets, through one of the Orbs. This rare experience, though confusing at first, has shaped your life and outlook. YOu have one additional Value, reflecting the insights you received. The first time this Value is challenged, roll 1 challenge die; if an effect is rolled, then some foretold element of the Orb Experience has come to pass, and the Value is not crossed out."),
new SpeciesRestrictedTalent("Bajoran", "String Pagh", "You believe profoundly in the Prophets, and rely heavily upon that faith to see you through hardship. Whenever you attempt a Task to resist being coerced or threatened, you reduce the Difficulty of that Task by 1."),
new SpeciesRestrictedTalent("Bajoran", "Strong Pagh", "You believe profoundly in the Prophets, and rely heavily upon that faith to see you through hardship. Whenever you attempt a Task to resist being coerced or threatened, you reduce the Difficulty of that Task by 1."),
new SpeciesRestrictedTalent("Betazoid", "Empath", "You can sense the emotions of most living beings nearby, and can communicate telepathically with other empaths and telepaths, as well as with whom you are extremely familiar. YOu cannot choose not to sense the emotions of those nearby except for those who are resistant to telepathy. It may require effort and a Task to pick out the emotions of a specific individual in a crowd, or to block out the emotions of those nearby. Increase the difficulty of the Task if the situation is stressful, there are lats of people present, if the target has resistance to telepathy, or other relevant factors."),
new SpeciesRestrictedTalent("Betazoid", "Telepath", "You can sense the surface thoughts and emotions of most living beings nearby, and can communicate telepathically with other empaths and telepaths, as well as those with whom you are extremely familiar. Surface thoughts are whatever a creature is thinking about at that precise moment. The character cannot choose not to sense the emotions or read the surface thoughts of those nearby, except for those that are resistant to telepathy. If will require effort and a Task to pick out the emotions or thoughts od a specific individual in a crowd, to search a creature;s mind for specific thoughts or memories, or to block out the minds of those nearby."),
new SpeciesRestrictedTalent("Denobulan", "Cultural Flexibility", "Your people are friendly, patient, and inquisitive, and you exemplify those traits. You are at ease when meeting new cultures, and adapt to unfamiliar social structures easily. When you attempt a Task to learn about an unfamiliar culture, or to act in the appropriate manner when interating with members of such a culture, you reduce the Difficulty by 1."),
Expand Down
22 changes: 22 additions & 0 deletions TrekSharp/src/Species.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using System.Collections.Generic;
using System.Linq;

namespace TrekSharp {

public class CustomSpecies : Species {
Expand All @@ -12,6 +15,8 @@ public class Species : IResearchableEntity {
public string Name {get; set;}
public Attributes AttributeModifiers {get; set;}

public List<Species> OtherHeritage {get; set;}

public Species () {}
public Species (string name, Attributes modifiers) {
this.Name = name;
Expand All @@ -33,6 +38,23 @@ public override int GetHashCode() {
public override string ToString(){
return this.Name;
}

public string ToFullString() {
return this.Name + (OtherHeritage == null || OtherHeritage.Count < 1 ? string.Empty : ("/" + string.Join('/',this.OtherHeritage)));
}

/// <summary>
/// Create a mixed species whose primary appearance and atttributes are derived from this species, but can have talents from other other constituent species.
/// </summary>
/// <param name="others">other species to mix with</param>
/// <returns>new mixed species</returns>
public Species DeriveMixedSpecies(IEnumerable<Species> others) {
return new Species {
Name = new string(this.Name),
AttributeModifiers = this.AttributeModifiers == null ? null : new Attributes(this.AttributeModifiers),
OtherHeritage = others?.ToList()
};
}
}

}
2 changes: 1 addition & 1 deletion TrekSharp/src/Talents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public SpeciesRestrictedTalent (string species, string name, string description)
this.species = species;
}
public override bool CanBeUsedBy(Character character) {
return character.Species.Name == this.species;
return character.Species.Name == this.species || (character.Species.OtherHeritage != null && character.Species.OtherHeritage.Select(s => s.Name).Contains(this.species));
}

}
Expand Down

0 comments on commit 9e83039

Please sign in to comment.