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()
|
||||
pokemonArr = []
|
||||
hasmega = false
|
||||
UberCount = 0
|
||||
PUCount = 0
|
||||
UnreleasedCount = 0
|
||||
DeltaCount = 0
|
||||
|
||||
|
||||
createTeamBookshelf = (format, requs, next) ->
|
||||
createTeam format, requs, (mons, teamname) ->
|
||||
|
@ -25,6 +30,10 @@ createTeamBookshelf = (format, requs, next) ->
|
|||
createTeam = (format, requs, next) ->
|
||||
pokemonArr = []
|
||||
hasmega = false
|
||||
UberCount = 0
|
||||
PUCount = 0
|
||||
UnreleasedCount = 0
|
||||
DeltaCount = 0
|
||||
|
||||
genTeam = ->
|
||||
conditions = Formats[format]
|
||||
|
@ -47,6 +56,14 @@ createTeam = (format, requs, next) ->
|
|||
if pokemonArr.length < 6
|
||||
generatePokemon list, generation, requs, (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()
|
||||
|
||||
|
@ -57,7 +74,7 @@ createTeam = (format, requs, next) ->
|
|||
console.log(err)
|
||||
genTeam()
|
||||
return
|
||||
teamname = "Random" + tier
|
||||
teamname = "Random"
|
||||
next(pokemonArr, teamname)
|
||||
genTeam()
|
||||
|
||||
|
@ -65,9 +82,8 @@ getValidFormes = (generation, tier, next) ->
|
|||
filteredlist = []
|
||||
fullList = gen.GenerationJSON[generation].RandomList
|
||||
for pok in fullList
|
||||
thistier = pok.tier[0]
|
||||
#If tier is correct and has random moves to choose from
|
||||
if thistier == tier and _.has pok, "randomMoves"
|
||||
#If has random moves to choose from
|
||||
if (_.has pok, "randomMoves") and pok.randomMoves.length >= 4
|
||||
filteredlist.push(pok)
|
||||
next(filteredlist)
|
||||
|
||||
|
@ -84,7 +100,24 @@ generatePokemon = (list, generation, requs, next) ->
|
|||
tryGenerate()
|
||||
return
|
||||
#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()
|
||||
return
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ class @BattleServer
|
|||
@randomqueues = {}
|
||||
allformats = ConditionsFunc.Formats()
|
||||
for format of allformats
|
||||
console.log(format)
|
||||
@queues[format] = new BattleQueue()
|
||||
@unrankedqueues[format] = new BattleQueue()
|
||||
@unrankedqueues[format].setUnranked()
|
||||
|
@ -233,7 +234,7 @@ class @BattleServer
|
|||
else if queuetype is "unranked"
|
||||
@unrankedqueues[format].add(playerId, altName || name, team, ratingKey)
|
||||
else if queuetype is "random"
|
||||
@randomqueues[format].add(playerId, altName || name, team, ratingKey)
|
||||
@randomqueues["insurUber"].add(playerId, altName || name, team, ratingKey)
|
||||
return err
|
||||
|
||||
queuedPlayers: (format = DEFAULT_FORMAT) ->
|
||||
|
@ -295,24 +296,24 @@ class @BattleServer
|
|||
# is correct, so make
|
||||
|
||||
queuedPlayersrandom: (format = DEFAULT_FORMAT) ->
|
||||
@randomqueues[format].queuedPlayers()
|
||||
@randomqueues["insurUber"].queuedPlayers()
|
||||
|
||||
removePlayerrandom: (playerId, format = DEFAULT_FORMAT) ->
|
||||
return false if format not of @randomqueues
|
||||
@randomqueues[format].remove(playerId)
|
||||
@randomqueues["insurUber"].remove(playerId)
|
||||
return true
|
||||
|
||||
beginBattlesrandom: (next) ->
|
||||
allformats = ConditionsFunc.Formats()
|
||||
array = for format in Object.keys(allformats)
|
||||
do (format) => (callback) =>
|
||||
@randomqueues[format].pairPlayers (err, pairs) =>
|
||||
@randomqueues["insurUber"].pairPlayers (err, pairs) =>
|
||||
if err then console.log(err)
|
||||
if err then return callback(err)
|
||||
# Create a battle for each pair
|
||||
battleIds = []
|
||||
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)
|
||||
callback(null, battleIds)
|
||||
async.parallel array, (err, battleIds) ->
|
||||
|
|
Loading…
Reference in New Issue