Skip to content

Commit

Permalink
Merge pull request #91 from HavlockV/develop
Browse files Browse the repository at this point in the history
0.2.9
  • Loading branch information
HavlockV authored Aug 22, 2020
2 parents dffeaa4 + 5b9897f commit 832ca26
Show file tree
Hide file tree
Showing 22 changed files with 385 additions and 253 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ Compendium 'Weapons' contains a single test weapon.

## What is working

version 0.2.9 :

* Bug fix forcing a fail or a pass should work as intended.
* Doing so will show a fail or a pass to the player.
* Bug fix, a combat roll will now flag the skill for experience correctly.
* You can now 'cheat' bu modifying the success level of the rolls before revealing the (blind rolls only)
* On blind rolls you have 2 new buttons for the keeper use only: increase/decrease success.
* Once your happy with the result push reveal check.
* Experience will not be flagged, keeper needs to manually award it with the corresponding button.
* On blind roll, the level of success will not be revealed until you push reveal check button.
* Pushing force fail/pass will just indicate to the player the failure or the success with no level indication.

version 0.2.8 :

* Bug fix/improvement on melee flow cards.
Expand Down
2 changes: 2 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
"CoC7.check.ForcePass": "Force pass",
"CoC7.check.ForceFail": "Force fail",
"CoC7.check.FlagForDevelopment": "Award experience",
"CoC7.check.IncreaseSuccessLevel": "Increase success",
"CoC7.check.DecreaseSuccessLevel": "Decrease success",

"CoC7.BonusSelectionWindow": "Bonus selection window",
"CoC7.RegularDifficulty": "regular",
Expand Down
10 changes: 10 additions & 0 deletions module/actors/sheets/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,20 @@ export class CoC7ActorSheet extends ActorSheet {
const token = this.actor.token;
data.tokenId = token ? `${token.scene._id}.${token.id}` : null;

data.hasEmptyValueWithFormula = false;
for ( const characteristic of Object.values(data.data.characteristics)){
if( !characteristic.value) characteristic.editable = true;
characteristic.hard = Math.floor( characteristic.value / 2);
characteristic.extreme = Math.floor( characteristic.value / 5);

//If no value && no formula don't display charac.
if( !characteristic.value && !characteristic.formula) characteristic.display = false;
else characteristic.display = true;

//if any characteristic has no value but has a formula.
if( !characteristic.value && characteristic.formula) characteristic.hasEmptyValueWithFormula = true;

data.hasEmptyValueWithFormula = data.hasEmptyValueWithFormula || characteristic.hasEmptyValueWithFormula;
}
}

Expand Down
133 changes: 30 additions & 103 deletions module/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1092,26 +1092,26 @@ export class CoC7Chat{
}
break;
}
case 'initiator-roll': { //Roll against each target
let initiatorRollActor = CoC7Chat.getActorFromToken( event.currentTarget.dataset.tokenId);
if( initiatorRollActor == null) initiatorRollActor = game.actors.get( event.currentTarget.dataset.actorId);
// case 'initiator-roll': { //Roll against each target
// let initiatorRollActor = CoC7Chat.getActorFromToken( event.currentTarget.dataset.tokenId);
// if( initiatorRollActor == null) initiatorRollActor = game.actors.get( event.currentTarget.dataset.actorId);

const initiatorCheck = new CoC7Check();
initiatorCheck.referenceMessageId = originMessage.dataset.messageId;
initiatorCheck.rollType= 'opposed';
initiatorCheck.side = 'initiator';
initiatorCheck.action = 'attack';
initiatorCheck.actor = initiatorRollActor;
initiatorCheck.difficulty = CoC7Check.difficultyLevel.regular;
if( event.currentTarget.dataset.outnumbered === 'true') initiatorCheck.diceModifier = +1;
// const initiatorCheck = new CoC7Check();
// initiatorCheck.referenceMessageId = originMessage.dataset.messageId;
// initiatorCheck.rollType= 'opposed';
// initiatorCheck.side = 'initiator';
// initiatorCheck.action = 'attack';
// initiatorCheck.actor = initiatorRollActor;
// initiatorCheck.difficulty = CoC7Check.difficultyLevel.regular;
// if( event.currentTarget.dataset.outnumbered === 'true') initiatorCheck.diceModifier = +1;

initiatorCheck.item = event.currentTarget.dataset.itemId;
// initiatorCheck.item = event.currentTarget.dataset.itemId;

initiatorCheck.roll();
initiatorCheck.toMessage();
// initiatorCheck.roll();
// initiatorCheck.toMessage();

break;
}
// break;
// }
case 'melee-initiator-roll':{
const initiator = CoC7MeleeInitiator.getFromCard( card);
await initiator.performSkillCheck( event.currentTarget.dataset.skill);
Expand Down Expand Up @@ -1169,11 +1169,24 @@ export class CoC7Chat{
break;
}

case 'increase-success-level':{
const check = await CoC7Check.getFromCard( card);
check.increaseSuccessLevel();
break;
}

case 'decrease-success-level':{
const check = await CoC7Check.getFromCard( card);
check.decreaseSuccessLevel();
break;
}

case 'reveal-check':{
const check = await CoC7Check.getFromCard( card);
check.isBlind = false;
check.computeCheck();
check.updateChatCard();
if( event.ctrlKey) check.updateChatCard( true);
else check.updateChatCard();
break;
}

Expand Down Expand Up @@ -1209,92 +1222,6 @@ export class CoC7Chat{
}
}

/**
* TODO : unclear, confusion itemId générique et ne dépend pas de l'acteur (plusieurs acteur avec meme itemId)
* @param {*} messageId
* @param {*} itemId
*/
// static messageContainsItem( messageId, itemId){
// const chatMessage = game.messages.get( messageId);
// return !chatMessage ? false : chatMessage.data.content.includes( itemId);
// }


// static getSceneControlButtons(buttons) {
// // console.log('-->CoC7Chat.getSceneControlButtons');
// let tokenButton = buttons.find(b => b.name == 'token');

// if (tokenButton) {
// tokenButton.tools.push({
// name: 'request-roll',
// title: 'Request Roll',
// icon: 'fas fa-dice',
// visible: game.user.isGM,
// onClick: () => CoC7Chat.createChatCard()
// });
// }
// }

// static async createChatCard(){
// const token = this.actor.token;
// const templateData = {
// actor: this.actor,
// tokenId: token ? `${token.scene._id}.${token.id}` : null,
// item: this.data
// };

// const template = 'systems/CoC7/templates/chat/skill-card.html';
// const html = await renderTemplate(template, templateData);

// // TODO change the speaker for the token name not actor name
// const speaker = ChatMessage.getSpeaker({actor: this.actor});
// if( token) speaker.alias = token.name;

// await ChatMessage.create({
// user: game.user._id,
// speaker,
// content: html
// });
// }

// static async createAttackCard(actorId, itemId, tokenKey = null){

// let actor = CoC7Chat.getActorFromToken( tokenKey);
// if( actor == null) actor = game.actors.get( actorId);

// if( !actor) {
// ui.notifications.error(game.i18n.format('CoC7.ErrorActor'));
// return;
// }

// const item = actor.getOwnedItem( itemId);
// if( !item) {
// ui.notifications.error(game.i18n.format('CoC7.ErrorItem'));
// return;
// }

// const templateData = {
// actor: actor,
// item: item,
// tokenKey: tokenKey
// };


// const template = 'systems/CoC7/templates/chat/close-combat-card.html';
// const html = await renderTemplate(template, templateData);

// const speaker = ChatMessage.getSpeaker({actor: actor});
// if( actor.isToken) speaker.alias = actor.token.name;

// const chatMessage = await ChatMessage.create({
// user: game.user._id,
// speaker,
// content: html
// });

// CoC7Chat.updatechatMessageTargets( chatMessage);
// }

static async updatechatMessageTargets( oldCard){
const htmlCardContent = jQuery.parseHTML( oldCard.data.content);
const targets = htmlCardContent[0].querySelector('.targets');
Expand Down
7 changes: 6 additions & 1 deletion module/chat/card-actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ export class ChatCardActor{

get isBlind(){
if( !this.rollMode) return null;
return 'blindroll' === this.rollMode;
if( undefined === this._isBlind) this._isBlind = 'blindroll' === this.rollMode;
return this._isBlind;
}

set isBlind(x){
this._isBlind = x;
}

get rollMode(){
Expand Down
6 changes: 5 additions & 1 deletion module/chat/combat/melee-initiator.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export class CoC7MeleeInitiator extends ChatCardActor{
};

if ( ['gmroll', 'blindroll'].includes(this.rollMode) ) chatData['whisper'] = ChatMessage.getWhisperRecipients('GM');
if ( this.isBlind ) chatData['blind'] = true;
// if ( this.isBlind ) chatData['blind'] = true;
chatData.blind = false;

const chatMessage = await ChatMessage.create(chatData);

Expand All @@ -65,6 +66,9 @@ export class CoC7MeleeInitiator extends ChatCardActor{

async performSkillCheck( skillId = null, publish = false){
const check = new CoC7Check();
// Combat roll cannot be blind or unknown
check.isBlind = false;
check.isUnkonwn = false;
check.referenceMessageId = this.messageId;
check.rollType= 'opposed';
check.side = 'initiator';
Expand Down
3 changes: 2 additions & 1 deletion module/chat/combat/melee-resolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export class CoC7MeleeResoltion{

let rollMode = game.settings.get('core', 'rollMode');
if ( ['gmroll', 'blindroll'].includes(rollMode) ) chatData['whisper'] = ChatMessage.getWhisperRecipients('GM');
if ( rollMode === 'blindroll' ) chatData['blind'] = true;
// if ( rollMode === 'blindroll' ) chatData['blind'] = true;
chatData.blind = false;

const chatMessage = await ChatMessage.create(chatData);
this.messageId = chatMessage.id;
Expand Down
6 changes: 5 additions & 1 deletion module/chat/combat/melee-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ export class CoC7MeleeTarget extends ChatCardActor{
};

if ( ['gmroll', 'blindroll'].includes(this.rollMode) ) chatData['whisper'] = ChatMessage.getWhisperRecipients('GM');
if ( this.isBlind ) chatData['blind'] = true;
// if ( this.isBlind ) chatData['blind'] = true;
chatData.blind = false;

const message = await ChatMessage.create(chatData);

Expand Down Expand Up @@ -184,6 +185,9 @@ export class CoC7MeleeTarget extends ChatCardActor{

async performSkillCheck( skillId = null, publish = false){
const check = new CoC7Check();
// Combat roll cannot be blind or unknown
check.isBlind = false;
check.isUnkonwn = false;
check.referenceMessageId = this.messageId;
check.rollType= 'opposed';
check.side = 'target';
Expand Down
5 changes: 3 additions & 2 deletions module/chat/damagecards.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class CoC7DamageRoll extends ChatCardActor{
} else {

let speakerData = {};
if( this.actorToken) speakerData.token = this.actorToken;
if( this.token) speakerData.token = this.token;
else speakerData.actor = this.actor;
const speaker = ChatMessage.getSpeaker(speakerData);
if( this.actor.isToken) speaker.alias = this.actor.token.name;
Expand All @@ -84,7 +84,8 @@ export class CoC7DamageRoll extends ChatCardActor{

let rollMode = game.settings.get('core', 'rollMode');
if ( ['gmroll', 'blindroll'].includes(rollMode) ) chatData['whisper'] = ChatMessage.getWhisperRecipients('GM');
if ( rollMode === 'blindroll' ) chatData['blind'] = true;
// if ( rollMode === 'blindroll' ) chatData['blind'] = true;
chatData.blind = false;

await ChatMessage.create(chatData);
}
Expand Down
14 changes: 9 additions & 5 deletions module/chat/rangecombat.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class CoC7RangeInitiator{
extremeRange: this.activeTarget.extremeRange,
actorKey: this.activeTarget.actorKey,
actorName: this.activeTarget.name,
difficultyLevel: this.activeTarget.shotDifficulty.level,
difficulty: this.activeTarget.shotDifficulty.level,
modifier: this.activeTarget.shotDifficulty.modifier,
damage: this.activeTarget.shotDifficulty.damage,
bulletsShot: 1,
Expand Down Expand Up @@ -299,7 +299,8 @@ export class CoC7RangeInitiator{

let rollMode = game.settings.get('core', 'rollMode');
if ( ['gmroll', 'blindroll'].includes(rollMode) ) chatData['whisper'] = ChatMessage.getWhisperRecipients('GM');
if ( rollMode === 'blindroll' ) chatData['blind'] = true;
// if ( rollMode === 'blindroll' ) chatData['blind'] = true;
chatData.blind = false;

const chatMessage = await ChatMessage.create(chatData);

Expand Down Expand Up @@ -355,7 +356,7 @@ export class CoC7RangeInitiator{
extremeRange: this.activeTarget.extremeRange,
actorKey: this.activeTarget.actorKey,
actorName: this.activeTarget.name,
difficultyLevel: this.activeTarget.shotDifficulty.level,
difficulty: this.activeTarget.shotDifficulty.level,
modifier: this.activeTarget.shotDifficulty.modifier,
damage: this.activeTarget.shotDifficulty.damage,
bulletsShot: 1,
Expand All @@ -380,10 +381,13 @@ export class CoC7RangeInitiator{
check.actorKey = this.actorKey;
check.actor = this.actorKey;
check.item = this.itemId;
// Combat roll cannot be blind or unknown
check.isBlind = false;
check.isUnkonwn = false;
if( this.autoFire) check.skill = this.autoWeaponSkill;
else check.skill = this.mainWeaponSkill;
if( this.multiTarget){
check.difficulty = shot.difficultyLevel;
check.difficulty = shot.difficulty;
check.diceModifier = shot.modifier;
} else {
this.calcTargetsDifficulty();
Expand Down Expand Up @@ -440,7 +444,7 @@ export class CoC7RangeInitiator{
const roll = this.rolls[rollIndex];
const luckAmount = parseInt(roll.luckNeeded);
if( !this.actor.spendLuck( luckAmount)){ ui.notifications.error(`${actor.name} does not have enough luck to pass the check`); return;}
roll.successLevel = roll.difficultyLevel;
roll.successLevel = roll.difficulty;
roll.isSuccess = true;
roll.luckSpent = true;
this.updateChatCard();
Expand Down
Loading

0 comments on commit 832ca26

Please sign in to comment.