Skip to content

Commit

Permalink
Merge pull request #201 from SolarBear/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
SolarBear authored Jul 24, 2021
2 parents 279fadd + 6f65b7c commit cdfa30e
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 27 deletions.
3 changes: 3 additions & 0 deletions module/actor/sheets/NumeneraPCActorSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ export class NumeneraPCActorSheet extends ActorSheet {
skillsTable.on("click", ".skill-delete", this.onSkillDelete.bind(this));
skillsTable.on("change", "input,select", this.onSkillEdit.bind(this));
skillsTable.on("click", "a.rollable", this.onSkillUse.bind(this));
skillsTable.on("click", ".skill-to-chat", this.onItemToChat.bind(this));

const weaponsTable = html.find("table.weapons");
weaponsTable.on("click", ".weapon-create", this.onWeaponCreate.bind(this));
Expand Down Expand Up @@ -598,12 +599,14 @@ export class NumeneraPCActorSheet extends ActorSheet {
powerShiftsTable.on("click", ".powerShift-create", this.onPowerShiftCreate.bind(this));
powerShiftsTable.on("click", ".powerShift-delete", this.onPowerShiftDelete.bind(this));
powerShiftsTable.on("blur", "input,select", this.onPowerShiftEdit.bind(this));
powerShiftsTable.on("click", ".power-shift-to-chat", this.onItemToChat.bind(this));
}

if (game.settings.get("numenera", "useRecursions")) {
const recursionTable = html.find("table.recursion");
recursionTable.on("blur", "input,select,textarea", this.onRecursionEdit.bind(this));
recursionTable.on("click", ".recursion-delete", this.onRecursionDelete.bind(this));
recursionTable.on("click", ".recursion-to-chat", this.onItemToChat.bind(this));
}

if (game.user.isGM) {
Expand Down
23 changes: 23 additions & 0 deletions module/item/NumeneraPowerShiftItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,27 @@ export class NumeneraPowerShiftItem extends Item {
itemData.effect = itemData.effect || Object.keys(NUMENERA.powerShiftEffects)[0];
itemData.level = itemData.level || 0;
}

//TODO all of these methods are mostly copy&paste... there's certainly a cleaner way to do this
async toChatMessage() {
const data = {
id: this.id,
actorId: this.actor.id,
type: this.type,
name: this.data.name,
img: this.data.img,
level: this.data.data.level,
effect: this.data.data.effect,
notes: this.data.data.notes,
};

await ChatMessage.create({
user: game.user.id,
speaker: ChatMessage.getSpeaker({user: game.user}),
content: await renderTemplate(
"systems/numenera/templates/chat/items/powerShift.html",
data,
)
});
}
}
46 changes: 45 additions & 1 deletion module/item/NumeneraSkillItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ export class NumeneraSkillItem extends Item {
itemData.skillLevel = itemData.skillLevel || 0;
}

get skillLevelDescription() {
//TODO this mix of integer values and shorthand for strings is messy... fix it!
switch(parseInt(this.data.data.skillLevel)) {
case 0:
return NUMENERA.skillLevels.u;

case 1:
return NUMENERA.skillLevels.t;

case 2:
return NUMENERA.skillLevels.s;

default:
throw new Error("Unknown skill level value " + this.data.data.skillLevel);
}
}

async getRelatedAbility() {
if (!this.data.data.relatedAbilityId)
return null;
Expand Down Expand Up @@ -97,8 +114,35 @@ export class NumeneraSkillItem extends Item {
const dialog = new EffortDialog(this.actor, { skill: this, ability });
await dialog.init();
return dialog.render(true);
} else {
}
else {
return await this.actor.rollSkill(this);
}
}

async toChatMessage() {
let level = game.i18n.localize(this.skillLevelDescription);
if (this.data.data.inability)
level += " + " + game.i18n.localize("NUMENERA.skillLevels.Inability");

const data = {
id: this.id,
actorId: this.actor.id,
type: this.type,
name: this.data.name,
img: this.data.img,
stat: this.data.data.stat,
level,
notes: this.data.data.notes,
};

await ChatMessage.create({
user: game.user.id,
speaker: ChatMessage.getSpeaker({user: game.user}),
content: await renderTemplate(
"systems/numenera/templates/chat/items/skill.html",
data,
)
});
}
}
26 changes: 26 additions & 0 deletions module/item/StrangeRecursionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,30 @@ export class StrangeRecursionItem extends Item {
itemData.focus = itemData.focus || "";
itemData.focusAbilities = itemData.focusAbilities || "";
}

async toChatMessage() {
const data = {
id: this.id,
actorId: this.actor.id,
type: this.type,
name: this.data.name,
img: this.data.img,
active: this.data.data.active ? "Yes" : "No",
level: this.data.data.level,
laws: this.data.data.laws,
race: this.data.data.race,
trait: this.data.data.trait,
focus: this.data.data.focus,
focusAbilities: this.data.data.focusAbilities,
};

await ChatMessage.create({
user: game.user.id,
speaker: ChatMessage.getSpeaker({user: game.user}),
content: await renderTemplate(
"systems/numenera/templates/chat/items/recursion.html",
data,
)
});
}
}
3 changes: 3 additions & 0 deletions module/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export const preloadHandlebarsTemplates = async() => {
"systems/numenera/templates/chat/items/cypher.html",
"systems/numenera/templates/chat/items/equipment.html",
"systems/numenera/templates/chat/items/oddity.html",
"systems/numenera/templates/chat/items/powerShift.html",
"systems/numenera/templates/chat/items/recursion.html",
"systems/numenera/templates/chat/items/skill.html",
"systems/numenera/templates/chat/items/weapon.html",

// Dialog Sheets
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "numenera-foundryvtt",
"version": "1.7.0",
"version": "1.7.1",
"description": "Support for the Cypher System (including Numenera and The Strange role playing games) for the Foundry virtual tabletop",
"devDependencies": {
"ava": "^3.13.0",
Expand Down
3 changes: 3 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const toBundle = [
"templates/chat/items/cypher.html",
"templates/chat/items/equipment.html",
"templates/chat/items/oddity.html",
"templates/chat/items/powerShift.html",
"templates/chat/items/recursion.html",
"templates/chat/items/skill.html",
"templates/chat/items/weapon.html",
"templates/dialog/effort.html",
"templates/dialog/recovery.html",
Expand Down
7 changes: 0 additions & 7 deletions sass/numenera.scss
Original file line number Diff line number Diff line change
Expand Up @@ -522,13 +522,6 @@ form.numenera {
vertical-align: center;
}

a.skill-delete {
padding-top: 0.65em;
display: block;
float: right;
margin: auto;
}

tbody td input[type="text"] {
text-align: left;
width: auto;
Expand Down
4 changes: 2 additions & 2 deletions system.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "numenera",
"title": "Numenera (Cypher System)",
"description": "Featureful support for Cypher system games, including Numenera and The Strange for the Fountry Virtual TableTop.",
"version": "1.7.0",
"version": "1.7.1",
"author": "SolarBear (David Lacerte)",
"scripts": [],
"esmodules": ["numenera.js"],
Expand Down Expand Up @@ -48,5 +48,5 @@
"compatibleCoreVersion": "0.8.8",
"url": "https://github.com/SolarBear/Numenera-FoundryVTT",
"manifest": "https://raw.githubusercontent.com/SolarBear/Numenera-FoundryVTT/master/system.json",
"download": "https://github.com/SolarBear/Numenera-FoundryVTT/releases/download/1.7.0/numenera-foundryvtt-1.7.0.zip"
"download": "https://github.com/SolarBear/Numenera-FoundryVTT/releases/download/1.7.1/numenera-foundryvtt-1.7.1.zip"
}
9 changes: 7 additions & 2 deletions templates/actor/characterSheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ <h2>{{localize "NUMENERA.pcActorSheet.advancement.title"}}</h2>
</thead>
<tbody class="row-container">
{{#each data.skills as |skill| }}
<tr class="skill" data-item-id="{{skill.id}}" data-order="{{skill.data.data.order}}">
<tr class="skill item" data-item-id="{{skill.id}}" data-order="{{skill.data.data.order}}">
<td class="handle">
<a><i class="fas fa-grip-vertical"></i></a>
</td>
Expand Down Expand Up @@ -170,7 +170,12 @@ <h2>{{localize "NUMENERA.pcActorSheet.advancement.title"}}</h2>
</td>
<td>
<a class="rollable"><img src="/icons/svg/d20-black.svg" title="{{localize "NUMENERA.item.tab.rollTooltip"}}" alt="d20" /></a>
<a class="skill-delete" data-action="delete" title="{{localize "NUMENERA.item.skill.tab.deleteTooltip"}}"><i class="fas fa-trash"></i></a>
<a class="skill-to-chat" data-action="to-chat" title="Send to chat">
<i class="fas fa-comment"></i>
</a>
<a class="skill-delete" data-action="delete" title="{{localize "NUMENERA.item.skill.tab.deleteTooltip"}}">
<i class="fas fa-trash"></i>
</a>
</td>
</tr>
{{else}}
Expand Down
13 changes: 8 additions & 5 deletions templates/actor/partials/powerShifts.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</thead>
<tbody class="row-container">
{{#each data.powerShifts as |powerShift|}}
<tr class="powerShift" data-item-id="{{powerShift.id}}" data-order="{{powerShift.data.order}}">
<tr class="powerShift item" data-item-id="{{powerShift.id}}" data-order="{{powerShift.data.data.order}}">
<td class="handle">
<a><i class="fas fa-grip-vertical"></i></a>
</td>
Expand All @@ -34,21 +34,24 @@
</td>
<td class="powerShift-effect">
<select name="data.powerShifts.{{powerShift.id}}.data.effect">
{{#select powerShift.data.effect}}
<option value=""></option>
{{#select powerShift.data.data.effect}}
<option value=""></op tion>
{{#each ../powerShiftEffects}}
<option value="{{this}}">{{localize this}}</option>
{{/each}}
{{/select}}
</select>
</td>
<td class="powerShift-description">
<input type="text" name="data.powerShifts.{{powerShift.id}}.data.notes" value="{{powerShift.data.notes}}" data-dtype="String" class="powerShift-description-input" />
<input type="text" name="data.powerShifts.{{powerShift.id}}.data.notes" value="{{powerShift.data.data.notes}}" data-dtype="String" class="powerShift-description-input" />
</td>
<td class="powerShift-level">
<input type="number" name="data.powerShifts.{{powerShift.id}}.data.level" value="{{powerShift.data.level}}" min="0" data-dtype="Number" />
<input type="number" name="data.powerShifts.{{powerShift.id}}.data.level" value="{{powerShift.data.data.level}}" min="0" data-dtype="Number" />
</td>
<td>
<a class="power-shift-to-chat" data-action="to-chat" title="Send to chat">
<i class="fas fa-comment"></i>
</a>
<a class="powerShift-delete" data-action="delete" title="{{localize "NUMENERA.pcActorSheet.features.powerShifts.deleteTooltip"}}">
<i class="fas fa-trash"></i>
</a>
Expand Down
23 changes: 14 additions & 9 deletions templates/actor/partials/recursions.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2>
{{localize "NUMENERA.pc.numenera.strange.alienation"}}
<input type="text" name="data.alienation" value="{{data.alienation}}" class="alienation" data-dtype="Number" />
<input type="text" name="data.alienation" value="{{data.data.alienation}}" class="alienation" data-dtype="Number" />
</h2>

<h2>
Expand All @@ -23,13 +23,13 @@ <h2>
</thead>
<tbody class="row-container">
{{#each data.recursion as |recursion|}}
<tr class="recursion" data-item-id="{{recursion.id}}" data-order="{{recursion.data.order}}">
<tr class="recursion item" data-item-id="{{recursion.id}}" data-order="{{recursion.data.data.order}}">
<td class="handle">
<a><i class="fas fa-grip-vertical"></i></a>
</td>

<td class="recursion-active">
<input type="checkbox" name="data.recursion.{{recursion.id}}.data.active" {{checked recursion.data.active}} data-dtype="Boolean" />
<input type="checkbox" name="data.recursion.{{recursion.id}}.data.active" {{checked recursion.data.data.active}} data-dtype="Boolean" />
</td>

<td class="recursion-icon">
Expand All @@ -41,27 +41,32 @@ <h4><strong>{{recursion.name}}</strong></h4>
</td>

<td class="recursion-level">
{{recursion.data.level}}
{{recursion.data.data.level}}
</td>

<td class="recursion-laws">
{{recursion.data.laws}}
{{recursion.data.data.laws}}
</td>

<td class="recursion-race">
<input type="text" name="data.recursion.{{recursion.id}}.data.race" value="{{recursion.data.race}}" title="{{recursion.data.race}}" />
<input type="text" name="data.recursion.{{recursion.id}}.data.race" value="{{recursion.data.data.race}}" title="{{recursion.data.race}}" />
</td>

<td class="recursion-focus">
<input type="text" name="data.recursion.{{recursion.id}}.data.focus" value="{{recursion.data.focus}}" title="{{recursion.data.focus}}" />
<input type="text" name="data.recursion.{{recursion.id}}.data.focus" value="{{recursion.data.data.focus}}" title="{{recursion.data.data.focus}}" />
</td>

<td class="recursion-focusAbilities">
<textarea name="data.recursion.{{recursion.id}}.data.focusAbilities">{{recursion.data.focusAbilities}}</textarea>
<textarea name="data.recursion.{{recursion.id}}.data.focusAbilities">{{recursion.data.data.focusAbilities}}</textarea>
</td>

<td>
<a class="recursion-delete" data-action="delete" title="{{localize "NUMENERA.item.recursion.tab.deleteTooltip"}}"><i class="fas fa-trash"></i></a>
<a class="recursion-to-chat" data-action="to-chat" title="Send to chat">
<i class="fas fa-comment"></i>
</a>
<a class="recursion-delete" data-action="delete" title="{{localize "NUMENERA.item.recursion.tab.deleteTooltip"}}">
<i class="fas fa-trash"></i>
</a>
</td>
</tr>
{{else}}
Expand Down
11 changes: 11 additions & 0 deletions templates/chat/items/powerShift.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="numenera chat">
<a class="sheet" data-id={{id}} data-actor-id={{actorId}}>
<span class="name">
<img src={{img}} />
{{capitalize type}}: {{name}}
</span>
</a><br/>
<span class="level">Level: {{level}}</span><br/>
<span class="effects">Effects: {{localize effect}}</span><br/>
<p>{{notes}}</p>
</div>
16 changes: 16 additions & 0 deletions templates/chat/items/recursion.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="numenera chat">
<a class="sheet" data-id={{id}} data-actor-id={{actorId}}>
<span class="name">
<img src={{img}} />
{{capitalize type}}: {{name}}
</span>
</a><br/>
<span class="active">Active: {{active}}</span><br/>
<span class="level">Level: {{level}}</span><br/>
<span class="laws">Laws: {{laws}}</span><br/>
<span class="race">Race: {{race}}</span><br/>
<span class="trait">Trait: {{trait}}</span><br/>
<span class="focus">Focus: {{focus}}</span><br/>
<span class="focusAbilities">Focus Abilities: {{focusAbilities}}</span>
<p>{{notes}}</p>
</div>
11 changes: 11 additions & 0 deletions templates/chat/items/skill.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="numenera chat">
<a class="sheet" data-id={{id}} data-actor-id={{actorId}}>
<span class="name">
<img src={{img}} />
{{capitalize type}}: {{name}}
</span>
</a><br/>
<span class="stat">Stat: {{localize stat}}</span><br/>
<span class="type">Level: {{level}}</span>
<p>{{notes}}</p>
</div>

0 comments on commit cdfa30e

Please sign in to comment.