Randoms no longer tier based. Increased chance of a delta in a team
This commit is contained in:
parent
f424a9fbd2
commit
20e59467d1
|
@ -6,6 +6,11 @@ FormatsClass = require '../shared/conditions'
|
||||||
Formats = FormatsClass.Formats()
|
Formats = FormatsClass.Formats()
|
||||||
pokemonArr = []
|
pokemonArr = []
|
||||||
hasmega = false
|
hasmega = false
|
||||||
|
UberCount = 0
|
||||||
|
PUCount = 0
|
||||||
|
UnreleasedCount = 0
|
||||||
|
DeltaCount = 0
|
||||||
|
|
||||||
|
|
||||||
createTeamBookshelf = (format, requs, next) ->
|
createTeamBookshelf = (format, requs, next) ->
|
||||||
createTeam format, requs, (mons, teamname) ->
|
createTeam format, requs, (mons, teamname) ->
|
||||||
|
@ -25,6 +30,10 @@ createTeamBookshelf = (format, requs, next) ->
|
||||||
createTeam = (format, requs, next) ->
|
createTeam = (format, requs, next) ->
|
||||||
pokemonArr = []
|
pokemonArr = []
|
||||||
hasmega = false
|
hasmega = false
|
||||||
|
UberCount = 0
|
||||||
|
PUCount = 0
|
||||||
|
UnreleasedCount = 0
|
||||||
|
DeltaCount = 0
|
||||||
|
|
||||||
genTeam = ->
|
genTeam = ->
|
||||||
conditions = Formats[format]
|
conditions = Formats[format]
|
||||||
|
@ -47,6 +56,14 @@ createTeam = (format, requs, next) ->
|
||||||
if pokemonArr.length < 6
|
if pokemonArr.length < 6
|
||||||
generatePokemon list, generation, requs, (pkmn) ->
|
generatePokemon list, generation, requs, (pkmn) ->
|
||||||
pokemonArr.push(pkmn)
|
pokemonArr.push(pkmn)
|
||||||
|
if (pkmn.tier == ["Uber"])
|
||||||
|
UberCount++
|
||||||
|
else if (pkmn.tier == ["PU"])
|
||||||
|
PUCount++
|
||||||
|
if _.has pkmn, "unreleased" and pkmn.unreleased is true
|
||||||
|
UnreleasedCount++
|
||||||
|
if /Delta/.test(pkmn.species)
|
||||||
|
DeltaCount++
|
||||||
getPokemonArr()
|
getPokemonArr()
|
||||||
getPokemonArr()
|
getPokemonArr()
|
||||||
|
|
||||||
|
@ -57,7 +74,7 @@ createTeam = (format, requs, next) ->
|
||||||
console.log(err)
|
console.log(err)
|
||||||
genTeam()
|
genTeam()
|
||||||
return
|
return
|
||||||
teamname = "Random" + tier
|
teamname = "Random"
|
||||||
next(pokemonArr, teamname)
|
next(pokemonArr, teamname)
|
||||||
genTeam()
|
genTeam()
|
||||||
|
|
||||||
|
@ -65,9 +82,8 @@ getValidFormes = (generation, tier, next) ->
|
||||||
filteredlist = []
|
filteredlist = []
|
||||||
fullList = gen.GenerationJSON[generation].RandomList
|
fullList = gen.GenerationJSON[generation].RandomList
|
||||||
for pok in fullList
|
for pok in fullList
|
||||||
thistier = pok.tier[0]
|
#If has random moves to choose from
|
||||||
#If tier is correct and has random moves to choose from
|
if (_.has pok, "randomMoves") and pok.randomMoves.length >= 4
|
||||||
if thistier == tier and _.has pok, "randomMoves"
|
|
||||||
filteredlist.push(pok)
|
filteredlist.push(pok)
|
||||||
next(filteredlist)
|
next(filteredlist)
|
||||||
|
|
||||||
|
@ -84,7 +100,24 @@ generatePokemon = (list, generation, requs, next) ->
|
||||||
tryGenerate()
|
tryGenerate()
|
||||||
return
|
return
|
||||||
#reject if we already have a mega
|
#reject if we already have a mega
|
||||||
if /mega/.test(pokemon.Forme) and hasmega
|
if /mega/.test(pokemon.Forme) and hasmega
|
||||||
|
tryGenerate()
|
||||||
|
return
|
||||||
|
|
||||||
|
#reject based on Uber count, PU count or unreleased count
|
||||||
|
if UberCount > 1 and pokemon.tier[0] is "Uber" and Math.floor(Math.random() * 5) > 0
|
||||||
|
tryGenerate()
|
||||||
|
return
|
||||||
|
if PUCount > 1 and pokemon.tier[0] is "PU" and Math.floor(Math.random() * 5) > 0
|
||||||
|
tryGenerate()
|
||||||
|
return
|
||||||
|
if UnreleasedCount > 1 and _.has pokemon, "unreleased" and pokemon.unreleased is true and Math.floor(Math.random() * 5) > 0
|
||||||
|
tryGenerate()
|
||||||
|
return
|
||||||
|
if pokemon.tier[0] is "LC" or pokemon.tier[0] is "AG"
|
||||||
|
tryGenerate()
|
||||||
|
return
|
||||||
|
if DeltaCount is 0 and !(/Delta/.test(pokemon.Name)) and Math.floor(Math.random() * 10) != 0
|
||||||
tryGenerate()
|
tryGenerate()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ class @BattleServer
|
||||||
@randomqueues = {}
|
@randomqueues = {}
|
||||||
allformats = ConditionsFunc.Formats()
|
allformats = ConditionsFunc.Formats()
|
||||||
for format of allformats
|
for format of allformats
|
||||||
|
console.log(format)
|
||||||
@queues[format] = new BattleQueue()
|
@queues[format] = new BattleQueue()
|
||||||
@unrankedqueues[format] = new BattleQueue()
|
@unrankedqueues[format] = new BattleQueue()
|
||||||
@unrankedqueues[format].setUnranked()
|
@unrankedqueues[format].setUnranked()
|
||||||
|
@ -233,7 +234,7 @@ class @BattleServer
|
||||||
else if queuetype is "unranked"
|
else if queuetype is "unranked"
|
||||||
@unrankedqueues[format].add(playerId, altName || name, team, ratingKey)
|
@unrankedqueues[format].add(playerId, altName || name, team, ratingKey)
|
||||||
else if queuetype is "random"
|
else if queuetype is "random"
|
||||||
@randomqueues[format].add(playerId, altName || name, team, ratingKey)
|
@randomqueues["insurUber"].add(playerId, altName || name, team, ratingKey)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
queuedPlayers: (format = DEFAULT_FORMAT) ->
|
queuedPlayers: (format = DEFAULT_FORMAT) ->
|
||||||
|
@ -295,24 +296,24 @@ class @BattleServer
|
||||||
# is correct, so make
|
# is correct, so make
|
||||||
|
|
||||||
queuedPlayersrandom: (format = DEFAULT_FORMAT) ->
|
queuedPlayersrandom: (format = DEFAULT_FORMAT) ->
|
||||||
@randomqueues[format].queuedPlayers()
|
@randomqueues["insurUber"].queuedPlayers()
|
||||||
|
|
||||||
removePlayerrandom: (playerId, format = DEFAULT_FORMAT) ->
|
removePlayerrandom: (playerId, format = DEFAULT_FORMAT) ->
|
||||||
return false if format not of @randomqueues
|
return false if format not of @randomqueues
|
||||||
@randomqueues[format].remove(playerId)
|
@randomqueues["insurUber"].remove(playerId)
|
||||||
return true
|
return true
|
||||||
|
|
||||||
beginBattlesrandom: (next) ->
|
beginBattlesrandom: (next) ->
|
||||||
allformats = ConditionsFunc.Formats()
|
allformats = ConditionsFunc.Formats()
|
||||||
array = for format in Object.keys(allformats)
|
array = for format in Object.keys(allformats)
|
||||||
do (format) => (callback) =>
|
do (format) => (callback) =>
|
||||||
@randomqueues[format].pairPlayers (err, pairs) =>
|
@randomqueues["insurUber"].pairPlayers (err, pairs) =>
|
||||||
if err then console.log(err)
|
if err then console.log(err)
|
||||||
if err then return callback(err)
|
if err then return callback(err)
|
||||||
# Create a battle for each pair
|
# Create a battle for each pair
|
||||||
battleIds = []
|
battleIds = []
|
||||||
for pair in pairs
|
for pair in pairs
|
||||||
id = @createBattle(format, pair, FIND_BATTLE_CONDITIONS_UNRANKED, true)
|
id = @createBattle("insurUber", pair, FIND_BATTLE_CONDITIONS_UNRANKED, true)
|
||||||
battleIds.push(id)
|
battleIds.push(id)
|
||||||
callback(null, battleIds)
|
callback(null, battleIds)
|
||||||
async.parallel array, (err, battleIds) ->
|
async.parallel array, (err, battleIds) ->
|
||||||
|
|
Loading…
Reference in New Issue