-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
235 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module.exports = { | ||
presets: ["@vue/cli-plugin-babel/preset"], | ||
plugins: ["wildcard"], | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
export default class Country { | ||
constructor(countryData) { | ||
this.title = countryData.title; | ||
this.description = ""; | ||
// this.attToRussia = countryData.attToRussia; | ||
this.attToRussia = this.getRandom(10); | ||
// this.initScriptsAtt = countryData.initScriptsAtt; | ||
this.initScriptsAtt = [ | ||
{ name: "bitcoin", value: this.getRandom(10) }, | ||
{ name: "space", value: this.getRandom(10) }, | ||
]; | ||
this.actualScriptsAtt = []; | ||
} | ||
getRandom(max) { | ||
return Math.floor(Math.random() * max * 2) - max; | ||
} | ||
getInitScriptAtt(scriptName) { | ||
const attitude = this.initScriptsAtt.find( | ||
(attitude) => attitude.name === scriptName | ||
); | ||
return attitude.value; | ||
} | ||
setActualScriptAtt(scriptName, scriptValue) { | ||
const attIndex = this.actualScriptsAtt.findIndex( | ||
(attitude) => attitude.name === scriptName | ||
); | ||
if (attIndex != -1) { | ||
this.actualScriptsAtt.splice(attIndex, 1, scriptValue); | ||
} else { | ||
this.actualScriptsAtt.push({ name: scriptName, value: scriptValue }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Bitcoin from "./scripts/Bitcoin"; | ||
import Space from "./scripts/Space"; | ||
|
||
export default class ScriptsCreator { | ||
createScript(type) { | ||
let script; | ||
switch (type) { | ||
case "bitcoin": | ||
script = new Bitcoin(); | ||
break; | ||
case "space": | ||
script = new Space(); | ||
break; | ||
} | ||
return script; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export default class Vote { | ||
constructor(countries, script) { | ||
this.resolution = script.title; | ||
this.ayes = []; | ||
this.nays = []; | ||
this.abstainers = []; | ||
this.getVotes(countries, script); | ||
} | ||
|
||
getVotes(countries, script) { | ||
countries.forEach((country) => { | ||
const countryAttitude = country.actualScriptsAtt.find( | ||
(attitude) => attitude.name === script.title | ||
); | ||
if (countryAttitude.value > 0) { | ||
this.ayes.push(country.title); | ||
} else if (countryAttitude.value < 0) { | ||
this.nays.push(country.title); | ||
} else { | ||
this.abstainers.push(country.title); | ||
} | ||
}); | ||
} | ||
|
||
countVotes(votes) { | ||
return votes.length; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export default class Bitcoin { | ||
constructor() { | ||
this.title = "bitcoin"; | ||
this.description = ""; | ||
this.optionName = | ||
"Принять Bitcoin в качестве международной резервной валюты"; | ||
this.active = false; | ||
} | ||
calculateCountryAtt(country) { | ||
return country.getInitScriptAtt(this.title) + country.attToRussia; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export default class Space { | ||
constructor() { | ||
this.title = "space"; | ||
this.description = ""; | ||
this.optionName = "Запрет на конкуренцию в космосе"; | ||
this.active = false; | ||
} | ||
spaceDaybonus() { | ||
const spaceDay = new Date(1961, 3, 12); | ||
const isToday = () => { | ||
const today = new Date(); | ||
return ( | ||
spaceDay.getDate() == today.getDate() && | ||
spaceDay.getMonth() == today.getMonth() | ||
); | ||
}; | ||
return isToday ? 5 : 0; | ||
} | ||
calculateCountryAtt(country) { | ||
return ( | ||
country.getInitScriptAtt(this.title) + | ||
country.attToRussia + | ||
this.spaceDaybonus() | ||
); | ||
} | ||
} |