Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP fix: change rolling #291

Merged
merged 2 commits into from
Jan 7, 2021
Merged

WIP fix: change rolling #291

merged 2 commits into from
Jan 7, 2021

Conversation

jonepatr
Copy link
Collaborator

@jonepatr jonepatr commented Jan 6, 2021

  • Please check if the PR fulfills these requirements
  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    Big change to how rolling is performed. Backward compatible, and using
    both methods for now. Not meant to be merged.

  • What is the current behavior? (You can also link to an open issue here)

  • What is the new behavior (if this is a feature change)?
    hopefully not much :) I removed the dropdown to select characteristics when rolling for a single characteristics. Other than that behavior should be the same

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
    No

  • Other information:

  • Fix Add support for ammunition and other consumables #212

@@ -112,13 +112,10 @@ const DIFFICULTIES = Object.freeze({
}
});

const CRIT = Object.freeze({"SUCCESS": 1, "FAIL": 2});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is simplified moved to twodsix.d.ts and simplified to a proper enum

return diceRoll;
}

public async rollDamage(rollMode:string, bonusDamage="", showInChat=true):Promise<Roll> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method is mostly unchanged. Some small changes.

@@ -56,8 +56,14 @@ export class TwodsixActorSheet extends AbstractTwodsixActorSheet {
super.activateListeners(html);

// Rollable abilities. Really should be in base class, but that will have to wait for issue 86

html.find('.rollable').on('click', (this._onRoll.bind(this)));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I kept the old way of making a throw. So that it's possible to compare to the old way

// somewhat worth it.
let skill: TwodsixItem;
try {
skill = TwodsixItem.createOwned(data, this.actor) as TwodsixItem;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, as the comment above says, this feels quite hacky. There are other ways to solve this, but the rest of the code becomes very nice by creating a temporary skill like this.

this.roll.roll();
}

constructor (settings: TwodsixRollSettings, actor: TwodsixActor, skill: TwodsixItem=null, item: TwodsixItem=null) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ops. Should be moved to the top of the class

import { getKeyByValue } from "./sheetUtils";
import { TwodsixRollSettings } from "./TwodsixRollSettings";

export class TwodsixDiceRoll {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class holds a twodsix skill/characteristic roll object, which is aware about effect, target, etc. It also can send a chat message about the result.

@mergify
Copy link

mergify bot commented Jan 6, 2021

This pull request is now in conflicts. Could you fix it? 🙏

import { getKeyByValue } from "./sheetUtils";


export class TwodsixRollSettings {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roll settings. It has a set of default settings which it will apply if it doesn't receive any specific settings. Can also ask for specifics through the dialog

@jonepatr jonepatr force-pushed the issue-212 branch 5 times, most recently from f4dbdc5 to 35abab1 Compare January 6, 2021 17:56
Big change to how rolling is performed. Backward compatible, and using
both methods for now. Not meant to be merged.

Fix xdy#212
change so that newItem flag is now set in the TwodsixItem.create
instead of setting it through a hook.
It's a bit cleaner to do this way.
@xdy
Copy link
Owner

xdy commented Jan 7, 2021

Jag tar och plockar in detta till pajon_refactor, ser bra ut.
Ska testa lite mer vid tillfälle under dagen, men tycker det lutar åt att pajon_refactor åker in på master.
Lite tveksam över att tmp_settings är ett Object, skulle föredra om det var nåt typsäkert (t ex en TwodsixRollSettingBuilder, dvs man sätter saker allt eftersom, och till slut anropar .build() för att få en TwodsixRollSetting). Men, det är petititesser, och det (eller nån annan bättre lösning) kan göras senare.

@xdy xdy merged commit 9fdf7a6 into xdy:pajon_refactor Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants