Skip to content

Commit

Permalink
Special rule with 5 players should work.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim committed Jan 4, 2021
1 parent 06caa70 commit 8c465d3
Show file tree
Hide file tree
Showing 26 changed files with 555 additions and 71 deletions.
Binary file not shown.
Binary file not shown.
Binary file modified .sass-cache/d874afac8be86f206bbd60dc9e094a050d42c8b5/task.scssc
Binary file not shown.
39 changes: 35 additions & 4 deletions modules/css/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ html,body {
/*
* YES/NO at the end of a mission
*/
#end-panel {
#end-panel, #give-task-panel {
display:none;
flex-flow: column;
justify-content: space-between;

// Checkmarks
#end-panel-top, #end-panel-bottom {
#end-panel-top, #end-panel-bottom, #give-task-panel-top, #give-task-panel-bottom {
display:flex;
justify-content: space-between;

Expand All @@ -197,7 +197,7 @@ html,body {
}

// Central line with question
#end-panel-middle {
#end-panel-middle, #give-task-panel-middle {
display: flex;
flex-flow:column;
align-items: center;
Expand All @@ -209,7 +209,7 @@ html,body {
font-size:16px;
}

#end-panel-buttons {
#end-panel-buttons, #give-task-buttons {
width: 100%;
display: flex;
flex-flow:row;
Expand Down Expand Up @@ -354,11 +354,42 @@ html,body {
}
}



/*
* Give task panel
*/
#give-task-panel {
#give-task-panel-middle {
#give-task-proposal {
display:flex;
flex-flow: column;
justify-content: center;
align-items: center;

#proposal-transaction {
display: flex;
align-items: center;
font-weight: bold;

.thecrew-arrow-down {
transform:rotate(-90deg);
margin:0;
width:60px;
height:60px;
}
}
}
}
}


// Focus on corresponding block
&[data-display='cards'] #cards-mat { display: flex; }
&[data-display='tasks'] #tasks { display: flex; }
&[data-display='end'] #end-panel { display:flex; }
&[data-display='distress'] #distress-panel { display:flex; }
&[data-display='give-task'] #give-task-panel { display:flex; }
}
}
}
Expand Down
49 changes: 37 additions & 12 deletions modules/css/mission.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
.thecrew-arrow-down {
width: 50px;
height: 50px;
background-image: url("img/sprites.png");
background-position: 70% 100%;
background-size: 1100%;
margin: 0 -10px;
}


#mission-status {
.open-book > * {
column-gap: 4em;
Expand Down Expand Up @@ -38,16 +48,40 @@
}

span#mission-counter {
clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
background: black;
display: inline-block;
width: 35px;
height: 35px;
color: white;
font-weight: bold;
font-size: 23px;
color: white;
line-height: 44px;
font-family: 'Crimson Text';
letter-spacing: 0px;
position:relative;

&::before, &::after {
content:'';
display: block;
clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
position:absolute;
top:0;
background: black;
width: 35px;
height: 35px;
z-index:-1;
}

&::before {
display: none;
}
&.special-rule::before {
display: block;
background: #e8a853;
width: 51px;
height: 51px;
left: -8px;
top: -9px;
}
}
}

Expand All @@ -63,15 +97,6 @@
@include shadow;
}

.thecrew-arrow-down {
width: 50px;
height: 50px;
background-image: url("img/sprites.png");
background-position: 70% 100%;
background-size: 1100%;
margin: 0 -10px;
}

#mission-informations-distribution {
display:flex;
justify-content: center;
Expand Down
5 changes: 5 additions & 0 deletions modules/css/task.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
}
}

&.selected {
animation:none;
box-shadow: 0 0 20px 3px #00ff00;
}

&.tile-selectable {
cursor:pointer;

Expand Down
2 changes: 1 addition & 1 deletion modules/js/Game/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ define(["dojo", "dojo/_base/declare","ebg/core/gamegui",], (dojo, declare) => {
* setupNotifications
*/
setupNotifications() {
console.log(this._notifications);
console.log("Setup notifications : ", this._notifications);
this._notifications.forEach(notif => {
var functionName = "notif_" + notif[0];

Expand Down
6 changes: 4 additions & 2 deletions modules/js/MissionTrait.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ define(["dojo", "dojo/_base/declare"], (dojo, declare) => {
dojo.empty(container);
let mission = this.gamedatas.missions[this.gamedatas.status.mId - 1];

// 5 players special rule
dojo.toggleClass('mission-counter', 'special-rule', mission.specialRule);

// Token commander
if(mission.hiddenTasks){
dojo.place(`<div id="mission-informations-commander"></div>`, container);
Expand Down Expand Up @@ -120,15 +123,14 @@ define(["dojo", "dojo/_base/declare"], (dojo, declare) => {
}

// Checkmarks
dojo.query("#end-panel .check-ok").addClass("check-confirm");
this.getActivePlayers().forEach(pId => dojo.removeClass("continue-ok-" + pId, "check-confirm"));
if(!this.isSpectator){
dojo.removeClass('comm-card-' + this.player_id, "selectable");
}
},

notif_continue(n){
dojo.addClass("continue-ok-" + n.args.player_id, "check-confirm");
dojo.query('#end-panel-buttons .finalbutton').toggleClass('hidden', this.player_id == n.args.player_id);
},

getMissionSpecialDescription(){
Expand Down
11 changes: 9 additions & 2 deletions modules/js/PlayerTrait.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ define(["dojo", "dojo/_base/declare"], (dojo, declare) => {
this.place('jstpl_playerTable', player, 'table-' + row);
this.place('jstpl_playerMat', player, 'card-mat-' + row);
this.place('jstpl_playerCheckMark', player, 'end-panel-' + row);
this.place('jstpl_playerCheckMarkGiveTask', player, 'give-task-panel-' + row);
this.place('jstpl_playerDistressChoice', player, 'distress-panel-' + row);
dojo.connect($('player-table-' + player.id), 'click', () => this.onClickPlayer(player.id));

Expand Down Expand Up @@ -133,7 +134,7 @@ define(["dojo", "dojo/_base/declare"], (dojo, declare) => {

makePlayersSelectable(players, callback){
this._callbackOnPlayer = callback;
this._selectablePlayers = players;
this._selectablePlayers = players.map(pId => parseInt(pId));

dojo.query(".player-table").removeClass("selectable").addClass("unselectable");
players.forEach(pId => {
Expand All @@ -142,8 +143,14 @@ define(["dojo", "dojo/_base/declare"], (dojo, declare) => {
});
},

clearSelectablePlayers(){
dojo.query(".player-table").removeClass("selectable unselectable");
this._selectablePlayers.forEach(pId => dojo.destroy('btnPlayer'+pId) );
this._selectablePlayers = [];
},

onClickPlayer(pId){
debug("Clicked on player : ", pId);
debug("Clicked on player : ", pId, this._selectablePlayers);

if(!this._selectablePlayers.includes(pId))
return;
Expand Down
109 changes: 109 additions & 0 deletions modules/js/States/GiveTaskTrait.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
define(["dojo", "dojo/_base/declare"], (dojo, declare) => {
return declare("thecrew.giveTaskTrait", null, {
constructor(){
this._notifications.push(
['confirmGiveTask', 10],
['giveTask', 1000]
);
},


onEnteringStateGiveTask(args){
debug("Give task", args);
this.switchCentralZone('');

if(!this.isSpectator){
this._selectedTask = null;
this.makeTaskSelectable(args.players[this.player_id], this.onChooseTaskToGive.bind(this));
if(this.isCurrentPlayerActive())
this.addPrimaryActionButton('btnPassGiveTask', _('Nothing to propose'), () => this.takeAction('actPassGiveTask') );
}
},

onChooseTaskToGive(task){
debug("Clicked on task ", task);

if(this._selectedTask != null){
var previousTask = this._selectedTask.id;
this.cancelSelectedTask();
if(previousTask == task.id)
return;
}

this._selectedTask = task;
dojo.addClass('task-' + task.id, "selected");
this.addSecondaryActionButton('btnCancelSelectedTask', _('Cancel'), () => this.cancelSelectedTask() );

let players = Object.keys(this.gamedatas.players).filter(pId => pId != this.player_id);
this.makePlayersSelectable(players, this.onClickPlayerToGiveTask.bind(this));
},

cancelSelectedTask(){
dojo.removeClass('task-' + this._selectedTask.id, "selected");
dojo.destroy("btnCancelSelectedTask");
this._selectedTask = null;
this.clearSelectablePlayers();
},

onClickPlayerToGiveTask(player){
debug("Clicked player to give task :", player)

if(!this.checkAction("actGiveTask"))
return false;

this.takeAction('actGiveTask', {
taskId : this._selectedTask.id,
pId : player,
});
},



onEnteringStateGiveTaskConfirmation(args){
this.switchCentralZone('give-task');

// Show proposal
dojo.empty('proposal-task');
this.addTask(args.task, 'proposal-task');
dojo.style('proposal-source', 'color', '#' + this.gamedatas.players[args.sourceId].color);
$('proposal-source').innerHTML = this.gamedatas.players[args.sourceId].name;
dojo.style('proposal-target', 'color', '#' + this.gamedatas.players[args.targetId].color);
$('proposal-target').innerHTML = this.gamedatas.players[args.targetId].name;

// Show/hide Yes/No buttons
let active = this.isCurrentPlayerActive() && this.player_id != args.sourceId;
dojo.query('#give-task-buttons .finalbutton').toggleClass('hidden', !active);
if(active){
this.connect($('agree-button'), 'click', () => this.takeAction("actConfirmGiveTask") );
this.connect($('reject-button'), 'click', () => this.takeAction("actRejectGiveTask") );
}
},

notif_confirmGiveTask(n){
dojo.addClass("give-task-ok-" + n.args.player_id, "check-confirm");
dojo.query('#give-task-buttons .finalbutton').toggleClass('hidden', this.player_id == n.args.player_id);
},


notif_giveTask(n) {
debug("Giving a task", n);
dojo.empty('proposal-task');

let task = n.args.task,
oTask = $('task-' + task.id);

this.attachToNewParent(oTask, 'player-table-missions-' + task.pId);

// Slide it
dojo.animateProperty({
node: oTask.id,
duration: 1000,
easing: dojo.fx.easing.expoInOut,
properties: {
left: 0,
top: 0,
}
}).play();
},
});
});
7 changes: 4 additions & 3 deletions modules/js/States/PickTaskTrait.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ define(["dojo", "dojo/_base/declare"], (dojo, declare) => {
this.makeTaskSelectable(args.tasks);
},

makeTaskSelectable(tasks){
makeTaskSelectable(tasks, callback = null){
callback = callback ?? this.onChooseTask.bind(this);

tasks.forEach(task => {
var oTask = $("task-" + task.id);
dojo.addClass(oTask, "selectable");
this.connect(oTask, 'click', () => this.onChooseTask(task) );
this.connect(oTask, 'click', () => callback(task) );
})
},

Expand Down Expand Up @@ -79,7 +81,6 @@ define(["dojo", "dojo/_base/declare"], (dojo, declare) => {
notif_taskUpdate(n){
debug("Update task status", n);
dojo.attr('task-' + n.args.task.id, 'data-status', n.args.task.status);
$task
},
});
});
Loading

0 comments on commit 8c465d3

Please sign in to comment.