diff --git a/README.md b/README.md index f2c0d6a8..593a250a 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,11 @@ Compendium 'Weapons' contains a single test weapon. ## What is working +vesion 0.4.0 : + +* Ready for 0.7.5 +* The latest version of 'Dice So Nice!' will not work with skills check. You have to keep an older version to see the dice. + version 0.3.9 : * Bug correction: diff --git a/coc7g.css b/coc7g.css index 5cfbee3d..3c4ba06b 100644 --- a/coc7g.css +++ b/coc7g.css @@ -30,6 +30,7 @@ flex-direction: row; flex-wrap: wrap; justify-content: flex-start; + width: 100%; } .flexrow > * { flex: 1; @@ -346,6 +347,7 @@ flex-direction: row; flex-wrap: wrap; justify-content: flex-start; + width: 100%; justify-content: flex-end; } .coc7.sheet.book .sheet-body .spell-list .item-controls > *, @@ -483,6 +485,7 @@ flex-direction: row; flex-wrap: wrap; justify-content: flex-start; + width: 100%; } .coc7 .form-group .form-fields > * { flex: 1; @@ -875,6 +878,7 @@ flex-direction: row; flex-wrap: wrap; justify-content: flex-start; + width: 100%; justify-content: flex-end; } .coc7.sheet.skill .sheet-body .spell-list .item-controls > *, @@ -1034,6 +1038,7 @@ flex-direction: row; flex-wrap: wrap; justify-content: flex-start; + width: 100%; justify-content: flex-end; height: 16px; } @@ -1226,6 +1231,7 @@ flex-direction: row; flex-wrap: wrap; justify-content: flex-start; + width: 100%; justify-content: flex-end; } .coc7.sheet.occupation .item-list .item-controls > * { diff --git a/less/variables.less b/less/variables.less index 9399ef77..6414db61 100644 --- a/less/variables.less +++ b/less/variables.less @@ -49,6 +49,7 @@ flex-direction: row; flex-wrap: wrap; justify-content: flex-start; + width: 100%; > * { flex: 1; diff --git a/module/actors/actor.js b/module/actors/actor.js index a94d184e..8a000d01 100644 --- a/module/actors/actor.js +++ b/module/actors/actor.js @@ -374,25 +374,6 @@ export class CoCActor extends Actor { return await super.createEmbeddedEntity(embeddedName, data, options); case 'weapon':{ - const mainSkill = data?.data?.skill?.main?.name; - if( mainSkill){ - let skill = this.getSkillsByName( mainSkill)[0]; - if( !skill){ - const name = mainSkill.match(/\(([^)]+)\)/)? mainSkill.match(/\(([^)]+)\)/)[1]: mainSkill; - skill = await this.createWeaponSkill( name, data.data.properties?.rngd ? true: false); - } - if( skill) data.data.skill.main.id = skill._id; - } //TODO : Else : selectionner le skill dans la liste ou en créer un nouveau - const secondSkill = data?.data?.skill?.alternativ?.name; - if( secondSkill){ - let skill = this.getSkillsByName( secondSkill)[0]; - if( !skill){ - const name = mainSkill.match(/\(([^)]+)\)/)? mainSkill.match(/\(([^)]+)\)/)[1]: mainSkill; - skill = await this.createWeaponSkill( name, data.data.properties?.rngd ? true: false); - } - if( skill) data.data.skill.alternativ.id = skill._id; - } //TODO : Else : selectionner le skill dans la liste ou en créer un nouveau - return await super.createEmbeddedEntity(embeddedName, data, options); } case 'setup':{ @@ -1039,7 +1020,7 @@ export class CoCActor extends Actor { item = game.items.get(skillData.id); } - if( !item) ui.notifications.warn(`No skill ${skillData.name? skillData.name : skillData} found for actor ${this.name}`); + if( !item) return ui.notifications.warn(`No skill ${skillData.name? skillData.name : skillData} found for actor ${this.name}`); let create = false; await Dialog.confirm({ @@ -1099,7 +1080,7 @@ export class CoCActor extends Actor { item = game.items.get(weaponData.id); } - if( !item) return ui.notifications.warning( game.i18n.localize( 'CoC7.WarnMacroNoItemFound')); + if( !item) return ui.notifications.warn( game.i18n.localize( 'CoC7.WarnMacroNoItemFound')); let create = false; await Dialog.confirm({ @@ -1108,7 +1089,30 @@ export class CoCActor extends Actor { yes: () => create = true }); - if(true == create){ await this.createOwnedItem( duplicate(item.data));} + if(true == create){ + + const mainSkill = item.data?.data?.skill?.main?.name; + if( mainSkill){ + let skill = this.getSkillsByName( mainSkill)[0]; + if( !skill){ + const name = mainSkill.match(/\(([^)]+)\)/)? mainSkill.match(/\(([^)]+)\)/)[1]: mainSkill; + skill = await this.createWeaponSkill( name, item.data.data.properties?.rngd ? true: false); + } + if( skill) item.data.data.skill.main.id = skill._id; + } //TODO : Else : selectionner le skill dans la liste ou en créer un nouveau. + + const secondSkill = item.data?.data?.skill?.alternativ?.name; + if( secondSkill){ + let skill = this.getSkillsByName( secondSkill)[0]; + if( !skill){ + const name = mainSkill.match(/\(([^)]+)\)/)? mainSkill.match(/\(([^)]+)\)/)[1]: mainSkill; + skill = await this.createWeaponSkill( name, item.data.data.properties?.rngd ? true: false); + } + if( skill) item.data.data.skill.alternativ.id = skill._id; + } //TODO : Else : selectionner le skill dans la liste ou en créer un nouveau. + + await this.createEmbeddedEntity('OwnedItem', duplicate(item.data)); + } else return; weapons = this.getItemsFromName( item.name); if( !weapons) return; diff --git a/module/chat/combat/melee-initiator.js b/module/chat/combat/melee-initiator.js index 2f9c2f7b..74b2f90c 100644 --- a/module/chat/combat/melee-initiator.js +++ b/module/chat/combat/melee-initiator.js @@ -36,8 +36,8 @@ export class CoC7MeleeInitiator extends ChatCardActor{ const html = await renderTemplate(this.template, this); const speakerData = {}; - if( this.token) speakerData.token = this.token; - else speakerData.actor = this.actor; + if( this.token) speakerData.token = this; + else speakerData.actor = this; const speaker = ChatMessage.getSpeaker(speakerData); const user = this.actor.user ? this.actor.user : game.user; diff --git a/module/chat/damagecards.js b/module/chat/damagecards.js index 74b96907..7594b4f3 100644 --- a/module/chat/damagecards.js +++ b/module/chat/damagecards.js @@ -28,18 +28,27 @@ export class CoC7DamageRoll extends ChatCardActor{ const is7 = Object.prototype.hasOwnProperty.call(Roll, 'cleanTerms'); + // 0.7.5 this.maxDamage.result -> this.maxDamage this.maxDamage = is7? Roll.maximize( this.rollString)._total: Roll.maximize( this.rollString); this.roll = null; if( this.critical){ if( this.weapon.impale) { - this.rollString = this.rollString + '+' + this.maxDamage.total; + if( is7) this.rollString = this.rollString + '+' + this.maxDamage; + else this.rollString = this.rollString + '+' + this.maxDamage.result; this.roll = new Roll( this.rollString); this.roll.roll(); this.result = Math.floor( this.roll.total); } else{ - this.result = this.maxDamage.total; - this.roll = this.maxDamage; + if( is7){ + this.roll = new Roll( `${this.maxDamage}`); + this.roll.roll(); + this.result = this.maxDamage; + } else { + this.roll = new Roll( this.maxDamage.result); + this.roll.roll(); + this.result = this.maxDamage.result; + } this.resultString = `Max(${this.rollString})`; } diff --git a/module/chat/helper.js b/module/chat/helper.js index 526e325c..1085f24a 100644 --- a/module/chat/helper.js +++ b/module/chat/helper.js @@ -61,6 +61,7 @@ export class chatHelper{ const tokenData = scene.getEmbeddedEntity('Token', tokenId); if (!tokenData) return null; const token = new Token(tokenData); + if( !token.scene) token.scene = scene; return token; } else { const actor = game.actors.get( key); @@ -113,6 +114,8 @@ export class chatHelper{ } static getDistance( startToken, endToken){ + // startToken.updateSource(); + // canvas.sight.initializeTokens(); const ray = new Ray( startToken.center, endToken.center); const segment = [{ray}]; const distance = { diff --git a/module/dice.js b/module/dice.js index 42358e80..a86de297 100644 --- a/module/dice.js +++ b/module/dice.js @@ -90,11 +90,16 @@ export class CoC7Dice { const diceData = { formula: `${tenDie.results.length}d100+1d10`, results: diceResults, + throws: [], whisper: null, blind: false }; - - game.dice3d.show(diceData); + + try{ + game.dice3d.show(diceData); + } catch(err){ + console.error('Roll: ' + err.message); + } } } diff --git a/system.json b/system.json index 0df45b3f..31f384fb 100644 --- a/system.json +++ b/system.json @@ -2,10 +2,10 @@ "name": "CoC7", "title": "The Call of Cthulhu 7th edition", "description": "The Call of Cthulhu 7th edition simple game system", - "version": "0.3.9", + "version": "0.4.0", "author": "HavelockV", "minimumCoreVersion": "0.5.2", - "compatibleCoreVersion": "0.6.6", + "compatibleCoreVersion": "0.7.5", "esmodules": [ "module/coc7.js", "module/dicebot.js" @@ -72,6 +72,6 @@ "secondaryTokenAttribute": "power", "url": "https://github.com/HavlockV/CoC7-FoundryVTT/", "manifest": "https://github.com/HavlockV/CoC7-FoundryVTT/raw/master/system.json", - "download": "https://github.com/HavlockV/CoC7-FoundryVTT/archive/0.3.9.zip" - } + "download": "https://github.com/HavlockV/CoC7-FoundryVTT/archive/0.4.0.zip" +} \ No newline at end of file