Skip to content

Commit

Permalink
Added the start of prepared spells Plus NPC levels
Browse files Browse the repository at this point in the history
  • Loading branch information
shaun-newsome committed Aug 16, 2019
1 parent c69f82a commit 896a868
Show file tree
Hide file tree
Showing 13 changed files with 254 additions and 91 deletions.
15 changes: 14 additions & 1 deletion css/pf2e.css
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,12 @@
display: grid;
grid: "one two three" 100% / auto 90px 20px;
}
.pf2e.actor .pf-two-grid {
grid-area: auto;
display: grid;
/* grid: "one two three" 100% / auto 90px 20px; */
grid: "one two" 100% / auto 90px;
}
.pf2e.actor .skills .lores-list {
margin: 0;
padding: 0;
Expand Down Expand Up @@ -1187,9 +1193,16 @@
.pf2e.actor .spellbook .skill > * {
flex: 1;
}
.pf2e.actor .skills .skill-name,
.pf2e.actor .skills .skill-name {
margin: 0;
align-self: center;
background: #b75b5b;
line-height: 32px;
color: white;
}
.pf2e.actor .spellbook .skill-name {
margin: 0;
text-align: center;
align-self: center;
background: #b75b5b;
line-height: 32px;
Expand Down
18 changes: 18 additions & 0 deletions scripts/actor/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ class ActorPF2e extends Actor {
data.attributes.spelldc.dc = data.attributes.spelldc.value + 10
data.attributes.spelldc.breakdown = `10 + ${spellAbl} modifier(${data.abilities[spellAbl].mod}) + proficiency(${spellProficiency}) + item bonus(${data.attributes.spelldc.item})`;

// Prepared Spell Slots
for (let spl of Object.values(data.spells)) {
if (spl.max) {
spl["prepared"] = spl["prepared"] || [];
for(var i = 0; i < spl.max; i++){
spl.prepared[i] = spl.prepared[i] || {
label: "Empty Slot",
spellId: null,
spell: {}
}
}
if (spl.prepared.length > spl.max) {
for (let i = 0; i < spl.prepared.length - spl.max; i++) {
i.pop();
}
}
}
}

// Skill modifiers
for (let skl of Object.values(data.skills)) {
Expand Down
3 changes: 2 additions & 1 deletion scripts/actor/sheet/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class ActorSheetPF2e extends ActorSheet {
isCantrip: lvl === 0,
label: CONFIG.spellLevels[lvl],
spells: [],
prepared: [],
uses: actorData.data.spells["spell"+lvl].value || 0,
slots: actorData.data.spells["spell"+lvl].max || 0
};
Expand Down Expand Up @@ -204,7 +205,7 @@ class ActorSheetPF2e extends ActorSheet {
});

// Roll Skill Checks
html.find('.skill-name').click(ev => {
html.find('.skill-name.rollable').click(ev => {
let skl = ev.currentTarget.parentElement.getAttribute("data-skill");
this.actor.rollSkill(ev, skl);
});
Expand Down
7 changes: 7 additions & 0 deletions scripts/actor/sheet/character.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ class ActorSheetPF2eCharacter extends ActorSheetPF2e {
if (hp.temp === 0) delete hp.temp;
if (hp.tempmax === 0) delete hp.tempmax;

// Spell Details
sheetData["magicTraditions"] = CONFIG.magicTraditions;
sheetData["preparationType"] = CONFIG.preparationType;
if ((sheetData.data.attributes.prepared || {}).value === "prepared") sheetData.data["preparedSpells"] = true;
else sheetData.data["preparedSpells"] = false;


// Return data for rendering
return sheetData;
}
Expand Down
16 changes: 14 additions & 2 deletions scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ CONFIG.weaponTraits = {
"volley": "Volley"
};



// Weapon Hands
CONFIG.weaponHands = {
"1": "One",
Expand Down Expand Up @@ -186,6 +184,20 @@ CONFIG.consumableTypes = {
"other": "Other"
};

// Magic Traditon
CONFIG.magicTraditions = {
"arcane": "Arcane",
"occult": "Occult",
"divine": "Divine",
"primal": "Primal"
};

// Preparation Type
CONFIG.preparationType = {
"prepared": "Prepared",
"spontaneous": "Spontaneous"
};

// Spell Traits
CONFIG.spellTraits = {
"attack": "Attack",
Expand Down
2 changes: 2 additions & 0 deletions scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ Hooks.once("init", () => {
"public/systems/pf2e/templates/actors/tabs/actor-inventory.html",
"public/systems/pf2e/templates/actors/tabs/actor-skills.html",
"public/systems/pf2e/templates/actors/tabs/actor-spellbook.html",
"public/systems/pf2e/templates/actors/tabs/actor-spellbook-prepared.html",
"public/systems/pf2e/templates/actors/tabs/actor-spellbook-spontaneous.html",

// Actor Sheet Partials (Legacy)
"public/systems/pf2e/templates/actors/actor-attributes.html",
Expand Down
2 changes: 1 addition & 1 deletion system.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pf2e",
"title": "Pathfinder 2nd Edition",
"description": "An early alpha game system for running games of Pathfinder 2nd Edition in the Foundry VTT environment.",
"version": 0.300,
"version": 0.301,
"author": "hooking",
"scripts": ["./scripts/init.js", "./scripts/config.js", "./scripts/actor/actor.js", "./scripts/actor/sheet/base.js", "./scripts/actor/sheet/character.js", "./scripts/actor/sheet/npc.js", "./scripts/item/item.js", "./scripts/item/sheet.js", "./scripts/actor/trait-selector.js", "./scripts/dice.js"],
"styles": ["./css/pf2e.css"],
Expand Down
9 changes: 9 additions & 0 deletions template.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@
"type": "String",
"label": "Class DC",
"item": 0
},
"tradition": {
"type": "String",
"label": "Magic Tradition"
},
"prepared": {
"type": "String",
"label": "Preperation Type",
"value": ""
}
},
"details": {
Expand Down
8 changes: 8 additions & 0 deletions templates/actors/npc-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
<h1 class="charname">
<input name="name" type="text" value="{{actor.name}}" placeholder="Character Name"/>
</h1>

<div class="charlevel">
<div class="level">
<label>Level </label>
<input name="data.details.level.value" type="text" value="{{data.details.level.value}}"
data-dtype="Number" placeholder="1"/>
</div>
</div>
</header>

<!-- SIDEBAR -->
Expand Down
71 changes: 71 additions & 0 deletions templates/actors/tabs/actor-spellbook-prepared.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<ol class="inventory-list directory-list">
{{#each actor.spellbook as |section lvl|}}
<li class="item inventory-header spellbook-header">
<div class="item-name flexrow">
<h3>{{section.label}}</h3>

{{#unless section.isCantrip}}
<!-- <span class="spell-slots-input">
<input type="text" name="data.spells.spell{{lvl}}.value" value="{{section.uses}}" placeholder="0"/>
</span>
<span class="flex0"> / </span> -->
<span class="spell-max-input">
<input type="text" name="data.spells.spell{{lvl}}.max" value="{{section.slots}}" placeholder="0"/>
</span>
{{else}}
<!-- <span class="spell-slots">&infin;</span>
<span class="flex0"> / </span> -->
<span class="spell-max">&infin;</span>
{{/unless}}
</div>

<div class="spell-school-header">School</div>
<div class="spell-action-header">Action</div>

{{#if ../owner}}
<div class="item-controls">
<a class="item-control item-create" title="Create Spell" data-type="spell"
data-level="{{lvl}}"><i class="fas fa-plus"></i> Add</a>
</div>
{{/if}}
</li>


{{#each section.spells as |item i|}}
<li class="item" data-item-id="{{item.id}}">
<div class="item-name rollable">
<div class="item-image" style="background-image: url({{item.img}})"></div>
<h4>{{item.name}}</h4>
</div>

<div class="spell-school">{{item.data.school.str}}</div>
<div class="spell-action">{{item.data.time.value}}</div>

{{#if ../../owner}}
<div class="item-controls" {{#if section.isCantrip}}style="padding-left:22px;"{{/if}}>
{{#unless section.isCantrip}}
{{#if item.data.prepared.value}}
<a class="item-control item-prepare" title="unprepare Spell"><i class="fas fa-haykal"></i></a>
{{else}}
<a class="item-control item-prepare" title="prepare Spell"><i class="fas fa-circle"></i></a>
{{/if}}
{{/unless}}
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
{{/if}}
</li>
{{/each}}


{{else}}
<li class="item inventory-header spellbook-header spellbook-empty">
{{#if owner}}
<div class="item-controls pf-bluelist">
<a class="item-control item-create" title="Create Spell" data-type="spell"
data-level="{{lvl}}"><i class="fas fa-plus"></i> Add Spell</a>
</div>
{{/if}}
</li>
{{/each}}
</ol>
71 changes: 71 additions & 0 deletions templates/actors/tabs/actor-spellbook-spontaneous.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<ol class="inventory-list directory-list">
{{#each actor.spellbook as |section lvl|}}
<li class="item inventory-header spellbook-header">
<div class="item-name flexrow">
<h3>{{section.label}}</h3>

{{#unless section.isCantrip}}
<span class="spell-slots-input">
<input type="text" name="data.spells.spell{{lvl}}.value" value="{{section.uses}}" placeholder="0"/>
</span>
<span class="flex0"> / </span>
<span class="spell-max-input">
<input type="text" name="data.spells.spell{{lvl}}.max" value="{{section.slots}}" placeholder="0"/>
</span>
{{else}}
<span class="spell-slots">&infin;</span>
<span class="flex0"> / </span>
<span class="spell-max">&infin;</span>
{{/unless}}
</div>

<div class="spell-school-header">School</div>
<div class="spell-action-header">Action</div>

{{#if ../owner}}
<div class="item-controls">
<a class="item-control item-create" title="Create Spell" data-type="spell"
data-level="{{lvl}}"><i class="fas fa-plus"></i> Add</a>
</div>
{{/if}}
</li>


{{#each section.spells as |item i|}}
<li class="item" data-item-id="{{item.id}}">
<div class="item-name rollable">
<div class="item-image" style="background-image: url({{item.img}})"></div>
<h4>{{item.name}}</h4>
</div>

<div class="spell-school">{{item.data.school.str}}</div>
<div class="spell-action">{{item.data.time.value}}</div>

{{#if ../../owner}}
<div class="item-controls" {{#if section.isCantrip}}style="padding-left:22px;"{{/if}}>
{{#unless section.isCantrip}}
{{#if item.data.prepared.value}}
<a class="item-control item-prepare" title="unprepare Spell"><i class="fas fa-haykal"></i></a>
{{else}}
<a class="item-control item-prepare" title="prepare Spell"><i class="fas fa-circle"></i></a>
{{/if}}
{{/unless}}
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
{{/if}}
</li>
{{/each}}


{{else}}
<li class="item inventory-header spellbook-header spellbook-empty">
{{#if owner}}
<div class="item-controls pf-bluelist">
<a class="item-control item-create" title="Create Spell" data-type="spell"
data-level="{{lvl}}"><i class="fas fa-plus"></i> Add Spell</a>
</div>
{{/if}}
</li>
{{/each}}
</ol>
Loading

0 comments on commit 896a868

Please sign in to comment.