mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-26 06:10:58 +00:00
Added graphic element to show the picking pattern (#142)
* added picking pattern * removed all changes to helpers
This commit is contained in:
parent
4fb3d7e22d
commit
3c253a7c4b
4 changed files with 100 additions and 20 deletions
|
@ -349,10 +349,12 @@ const GatherActions = React.createClass({
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let regatherButton;
|
let regatherButton;
|
||||||
|
let pickPatternIndicator;
|
||||||
const user = this.props.user;
|
const user = this.props.user;
|
||||||
const gather = this.props.gather;
|
const gather = this.props.gather;
|
||||||
const socket = this.props.socket;
|
const socket = this.props.socket;
|
||||||
const thisGatherer = this.props.thisGatherer;
|
const thisGatherer = this.props.thisGatherer;
|
||||||
|
let pickIndex = this.props.gather.pickingTurnIndex - 1;
|
||||||
if (thisGatherer) {
|
if (thisGatherer) {
|
||||||
let regatherVotes = this.regatherVotes();
|
let regatherVotes = this.regatherVotes();
|
||||||
if (thisGatherer.regatherVote) {
|
if (thisGatherer.regatherVote) {
|
||||||
|
@ -366,19 +368,42 @@ const GatherActions = React.createClass({
|
||||||
{`Vote Regather (${regatherVotes}/8)`}
|
{`Vote Regather (${regatherVotes}/8)`}
|
||||||
</button>;
|
</button>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pickPatternIndicator = <ul className="list-inline">
|
||||||
|
{gather.pickingPattern.map((team, index) => {
|
||||||
|
if (team === 'alien') {
|
||||||
|
if (index <= pickIndex) {
|
||||||
|
return <li className="padding-y-1"><div className="pick-pattern-box alien-box-active"></div></li>
|
||||||
|
}else{
|
||||||
|
return <li className="padding-y-1"><div className="pick-pattern-box alien-box"></div></li>
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (index <= pickIndex) {
|
||||||
|
return <li className="padding-y-1"><div className="pick-pattern-box marine-box-active"></div></li>
|
||||||
|
}else{
|
||||||
|
return <li className="padding-y-1"><div className="pick-pattern-box marine-box"></div></li>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})}
|
||||||
|
</ul>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="text-right">
|
<div className="text-right">
|
||||||
<ul className="list-inline no-bottom">
|
<ul className="list-inline no-bottom content-center">
|
||||||
<li>
|
<li>
|
||||||
<JoinGatherButton gather={gather} thisGatherer={thisGatherer}
|
{pickPatternIndicator}
|
||||||
user={user} socket={socket} />
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
{regatherButton}
|
|
||||||
</li>
|
</li>
|
||||||
|
<ul className='list-inline no-bottom'>
|
||||||
|
<li className='padding-right-0'>
|
||||||
|
<JoinGatherButton gather={gather} thisGatherer={thisGatherer}
|
||||||
|
user={user} socket={socket} />
|
||||||
|
</li>
|
||||||
|
<li className='padding-right-0'>
|
||||||
|
{regatherButton}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -332,7 +332,52 @@ html, body {
|
||||||
|
|
||||||
/* minimized drawer gather icons */
|
/* minimized drawer gather icons */
|
||||||
|
|
||||||
.gatherTypeIcons{
|
.gatherTypeIcons {
|
||||||
width: 35px;
|
width: 35px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* pick pattern */
|
||||||
|
|
||||||
|
.float-left {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pick-pattern-box {
|
||||||
|
width: 75px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.marine-box {
|
||||||
|
background-color: #2c689c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alien-box {
|
||||||
|
background-color: #9c602c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.marine-box-active {
|
||||||
|
box-shadow: 0px 0px 4px 0px #0072ff;
|
||||||
|
background-color: #0072ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alien-box-active {
|
||||||
|
box-shadow: 0px 0px 4px 0px #ff8e00;
|
||||||
|
background-color: #ff8e00;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-center {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.padding-right-0 {
|
||||||
|
padding-right: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.padding-y-1 {
|
||||||
|
padding-top: 2px;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,15 +257,7 @@ Gather.prototype.modifyGatherer = function (user, callback){
|
||||||
.forEach(callback);
|
.forEach(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Determines picking order of teams
|
Gather.prototype.getPickingPattern = function () {
|
||||||
// Marine pick first
|
|
||||||
Gather.prototype.pickingTurn = function () {
|
|
||||||
if (this.current !== 'selection') return null;
|
|
||||||
|
|
||||||
const captainCount = 2;
|
|
||||||
const alienCount = this.aliens().length;
|
|
||||||
const marineCount = this.marines().length;
|
|
||||||
const alreadyPickedCount = (marineCount + alienCount) - captainCount;
|
|
||||||
const pickingPattern = [ // 1-2-2-2-2-2-1
|
const pickingPattern = [ // 1-2-2-2-2-2-1
|
||||||
"marine",
|
"marine",
|
||||||
"alien",
|
"alien",
|
||||||
|
@ -281,6 +273,20 @@ Gather.prototype.pickingTurn = function () {
|
||||||
"marine",
|
"marine",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
return pickingPattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determines picking order of teams
|
||||||
|
// Marine pick first
|
||||||
|
Gather.prototype.pickingTurnIndex = function () {
|
||||||
|
if (this.current !== 'selection') return null;
|
||||||
|
|
||||||
|
const captainCount = 2;
|
||||||
|
const alienCount = this.aliens().length;
|
||||||
|
const marineCount = this.marines().length;
|
||||||
|
const alreadyPickedCount = (marineCount + alienCount) - captainCount;
|
||||||
|
const pickingPattern = this.getPickingPattern();
|
||||||
|
|
||||||
const pickingTurn = alreadyPickedCount % pickingPattern.length;
|
const pickingTurn = alreadyPickedCount % pickingPattern.length;
|
||||||
|
|
||||||
// prevent any team from growing beyond the team size limit
|
// prevent any team from growing beyond the team size limit
|
||||||
|
@ -290,7 +296,7 @@ Gather.prototype.pickingTurn = function () {
|
||||||
return "marine";
|
return "marine";
|
||||||
}
|
}
|
||||||
|
|
||||||
return pickingPattern[pickingTurn];
|
return pickingTurn;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Moves player to marine
|
// Moves player to marine
|
||||||
|
@ -303,7 +309,7 @@ Gather.prototype.moveToMarine = function (user, mover) {
|
||||||
let leader = this.getGatherer(mover);
|
let leader = this.getGatherer(mover);
|
||||||
if (leader.team !== "marine" ||
|
if (leader.team !== "marine" ||
|
||||||
!leader.leader ||
|
!leader.leader ||
|
||||||
this.pickingTurn() !== "marine") return;
|
this.pickingPattern()[this.pickingTurnIndex()] !== "marine") return;
|
||||||
|
|
||||||
if (user && this.containsUser(user)) {
|
if (user && this.containsUser(user)) {
|
||||||
if (this.getGatherer(user).team !== "lobby") return;
|
if (this.getGatherer(user).team !== "lobby") return;
|
||||||
|
@ -324,7 +330,7 @@ Gather.prototype.moveToAlien = function (user, mover) {
|
||||||
let leader = this.getGatherer(mover);
|
let leader = this.getGatherer(mover);
|
||||||
if (leader.team !== "alien" ||
|
if (leader.team !== "alien" ||
|
||||||
!leader.leader ||
|
!leader.leader ||
|
||||||
this.pickingTurn() !== "alien") return;
|
this.getPickingPattern()[this.pickingTurnIndex()] !== "alien") return;
|
||||||
|
|
||||||
if (user && this.containsUser(user)) {
|
if (user && this.containsUser(user)) {
|
||||||
if (this.getGatherer(user).team !== "lobby") return;
|
if (this.getGatherer(user).team !== "lobby") return;
|
||||||
|
@ -368,7 +374,9 @@ Gather.prototype.toJson = function () {
|
||||||
gatherers: this.gatherers,
|
gatherers: this.gatherers,
|
||||||
servers: this.getServers(),
|
servers: this.getServers(),
|
||||||
state: this.current,
|
state: this.current,
|
||||||
pickingTurn: this.pickingTurn(),
|
pickingTurn: this.getPickingPattern()[this.pickingTurnIndex()],
|
||||||
|
pickingTurnIndex: this.pickingTurnIndex(),
|
||||||
|
pickingPattern: this.getPickingPattern().splice(0, this.getPickingPattern().length-2), //why is the picking pattern length 12 anyway ? 12 - 2 captains
|
||||||
election: {
|
election: {
|
||||||
startTime: this.electionStartTime(),
|
startTime: this.electionStartTime(),
|
||||||
interval: this.election.INTERVAL
|
interval: this.election.INTERVAL
|
||||||
|
|
|
@ -15,3 +15,5 @@ var getRandomUser = callback => {
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getRandomUser: getRandomUser
|
getRandomUser: getRandomUser
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue