Skip to content

Commit

Permalink
fix aborted rolls
Browse files Browse the repository at this point in the history
fix drag and drop in recipesheet.
  • Loading branch information
AngryBeaver committed Apr 20, 2023
1 parent 4030fc2 commit 068f98b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 15 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog
## 3.1.x folders
## 3.1.5
- handle null rolls
- systeminterface return type of rolls maybe null (if aborted)
- fix drag and drop in recipesheet for some systems.
## 3.1.3
- fix always revert currency on failed crafts.
- fix on enter open crafting tab.
Expand Down
6 changes: 3 additions & 3 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Beaver's Crafting Module",
"description": "A Crafting Module for DnD",
"id": "beavers-crafting",
"version": "3.1.4",
"version": "3.1.5",
"authors": [
{
"name": "angryBeaver",
Expand Down Expand Up @@ -44,8 +44,8 @@
"type": "module",
"manifest": "https://github.com/AngryBeaver/beavers-system-interface/releases/latest/download/module.json",
"compatibility": {
"minimum" : "2.1.0",
"verified": "2.1.0"
"minimum" : "2.1.1",
"verified": "2.1.1"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "beavers-crafting",
"title": "Beaver's Crafting",
"version": "3.1.4",
"version": "3.1.5",
"description": "Crafting",
"devDir": "C:\\Users\\Riess\\AppData\\Local\\FoundryVTT\\Data\\modules",
"#devDir": "C:\\data\\Data\\modules",
Expand All @@ -24,7 +24,7 @@
"printWidth": 120
},
"devDependencies": {
"beavers-system-interface": "^2.1.0",
"beavers-system-interface": "^2.1.1",
"@ethaks/fvtt-quench": "^0.6.0",
"@league-of-foundry-developers/foundry-vtt-types": "^0.8.8-9",
"@types/jest": "^27.4.1",
Expand Down
1 change: 1 addition & 0 deletions src/Crafting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ export class Crafting implements CraftingData {
component.quantity = component.quantity * -1;
this.restore.forEach(r=>{
if(component.isSame(r)){
r.quantity = component.quantity;
r.quantity = component.quantity;
component = beaversSystemInterface.componentCreate(r);
}
Expand Down
21 changes: 15 additions & 6 deletions src/TestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class TestHandler{

async test(){
const testOr = await this.selectTestChoice();
let test = false;
let test:boolean|null = null;
if(testOr.type === "ability") {
test = await this._testAbility(testOr);
}else if(testOr.type === "skill") {
Expand All @@ -67,30 +67,36 @@ export class TestHandler{
test = true;
}
//todo time,hook,macro,item
if(test){
if(test === true){
this.result.updateTests(1,0);
}else{
}else if(test === false){
this.result.updateTests(0,1);
}
}

async _testAbility(testOr:TestOr):Promise<boolean>{
async _testAbility(testOr:TestOr):Promise<boolean|null>{
let roll = await beaversSystemInterface.actorRollAbility(this.actor, testOr.uuid);
if( roll == null){
return null
}
if(roll != undefined && roll.total >= testOr.check){
return true;
}
return false;
}

async _testSkill(testOr:TestOr):Promise<boolean>{
async _testSkill(testOr:TestOr):Promise<boolean|null>{
let roll = await beaversSystemInterface.actorRollSkill(this.actor, testOr.uuid);
if( roll == null){
return null;
}
if(roll != undefined && roll.total >= testOr.check){
return true;
}
return false;
}

async _testTool(testOr:TestOr):Promise<boolean>{
async _testTool(testOr:TestOr):Promise<boolean|null>{
const item = await beaversSystemInterface.uuidToDocument(testOr.uuid);
const toolComponent = beaversSystemInterface.componentFromEntity(item);
const results = beaversSystemInterface.itemListComponentFind(this.actor.items,toolComponent);
Expand All @@ -102,6 +108,9 @@ export class TestHandler{
}
const actorItem = await beaversSystemInterface.uuidToDocument(actorComponent.uuid);
let roll = await beaversSystemInterface.actorRollTool(this.actor, actorItem);
if( roll == null ){
return null;
}
if(roll != undefined && roll.total >= testOr.check){
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions src/apps/RecipeSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class RecipeSheet {
addDragDrop(){
if(this.editable) {
const dragDrop = new DragDrop({
dropSelector: '.sheet-body',
dropSelector: '',
permissions: {
dragstart: this.app._canDragStart.bind(this.app),
drop: this.app._canDragDrop.bind(this.app)
Expand Down Expand Up @@ -228,9 +228,9 @@ export class RecipeSheet {


async _onDropMain(e){
const isIngredient = $(e.target).parents(".beavers-crafting .recipe .ingredients").length !==0;
const isResult = $(e.target).parents(".beavers-crafting .recipe .results").length !==0;
const isAttendant = $(e.target).parents(".beavers-crafting .recipe .attendants").length !==0;
const isIngredient = $(e.target).parents(".beavers-crafting.recipe .ingredients").length !==0;
const isResult = $(e.target).parents(".beavers-crafting.recipe .results").length !==0;
const isAttendant = $(e.target).parents(".beavers-crafting.recipe .attendants").length !==0;
if(!isIngredient && !isResult && !isAttendant){
return;
}
Expand Down

0 comments on commit 068f98b

Please sign in to comment.