ID:144470
 
Code:
if(C.ChuuninScore>=1&&C.AnsweredTen)
C<<"<font size=1><i><b>You have passed the written part of the Chuunin exam!</font></i></b>"
C<<"<font size=1><i>You must now compete in the Forest of Death. You will be given either the Heaven or Earth Scroll. You must find the scroll that you do <b>not</b> have, and bring them to the tower in the centre of the forest. Do this by any means necessary.</font></i>"
//above works fine
spawn(100)
C.loc=locate(133,475,2) //would prefer each participant gets sent to a different location as designated by me
C.InTower=1 //this is a var made true for purposes of testing (so I don't have to 'win' to test it)
spawn(100)
var/count=0
for(C in world)
count+=1
if(C.InTower)
C<<"<font size=1><i><b>You have passed the second part of the Chuunin exam!</font></i></b>"
C<<"<font size=1><i>In the third stage of the exams, ninjas must fight one on one with the other remaining ninjas, until one is left.</font></i>"
spawn(100)
if(count<=0) //if there's no one left do nothing, probably won't need it later
return
if(count==1)
C<<"<font size=1><i><b>You are now a Chuunin by default!</font></i></b>"
C.NinjaRank="Chuunin"
//the two above lines are supposed to make it so that if only one player's left, they automatically win
if(count>1&&!C.chosen)
C.chosen=1
C.loc=locate(70,425,2)
if(!C.chosen)
C.chosen=1
C.loc=locate(75,425,2)
//and this is supposed to send 2 of the remaining players (which could be any number in total) to TWO DIFFERENT locations as designated by me
//as long as there's more than one player in the thingy


Problem description:
Right so the battle code I'm working on making, it works fine up to here (where this code starts).
I kind of understand why I'm getting the bugs (explained below), but I definitely don't know how to remedy them. I'm also sure there is a better way.
Bugs:
-If there are three contenders, 2 will be sent to the same coords, not different. And the third "is chuunin by default", three times.

-Same thing occurs with 2 players, except one player is sent, and one is winner by default twice.


What I WANT to happen:

*X number of players take an exam (series of swtiches) via a verb attached to an obj
*Whichever such players meet the exam requirements, get moved to however many different pre-designated locations.
*Players that are not killed in this round, and have certain variables as true, are selected two at a time to be sent to an arena
*1-on-1, players will fight. The loser is kicked out, winner is sent back to waiting room. And the winners do not get selected again until the next round (each time, halving the number)
*This continues until 1 is left.
~Provisions made incase player count is an odd number.

Cheers... ~:|


Would a system of using lists be better?
if(C.ChuuninScore>=1&&C.AnsweredTen)
C<<"<font size=1><i><b>You have passed the written part of the Chuunin exam!</font></i></b>"
C<<"<font size=1><i>You must now compete in the Forest of Death. You will be given either the Heaven or Earth Scroll. You must find the scroll that you do <b>not</b> have, and bring them to the tower in the centre of the forest. Do this by any means necessary.</font></i>"
//above works fine
spawn(100)
C.loc=locate(133,475,2) //would prefer each participant gets sent to a different location as designated by me
C.InTower=1 //this is a var made true for purposes of testing (so I don't have to 'win' to test it)
spawn(100)
var/count=0
for(C in world)
count+=1
if(C.InTower)
C<<"<font size=1><i><b>You have passed the second part of the Chuunin exam!</font></i></b>"
C<<"<font size=1><i>In the third stage of the exams, ninjas must fight one on one with the other remaining ninjas, until one is left.</font></i>"
spawn(100)
if(count<=0) //if there's no one left do nothing, probably won't need it later
return
if(count==1)
C<<"<font size=1><i><b>You are now a Chuunin by default!</font></i></b>"
C.NinjaRank="Chuunin"
//the two above lines are supposed to make it so that if only one player's left, they automatically win
if(count>1&&!C.chosen)
C.chosen=1
C.loc=locate(70,425,2)
if(!C.chosen)<---Make that chosen = 2
C.chosen=1<--- same here
C.loc=locate(75,425,2)
//and this is supposed to send 2 of the remaining players (which could be any number in total) to TWO DIFFERENT locations as designated by me
//as long as there's more than one player in the thingy

I'm guessing but not fully sure.
~Grand~
In response to KillerGrand
Definitely not. For starters, its the variable "count" thats getting bigger, and its used to determine how many players fit into the category.
The 'chosen' variable is given to make sure that the same player is not chosen twice (well at least, if my system worked, it would ensure the same player is not chosen twice).
The 'chosen' variable is also in boolean, ie. true or false, 1 or 0
In response to CuriousNeptune
K.
Lists seem the logical solution and I'm pretty confident It'll work (and better than first expected).
However, I don't know how I can call just one player from a list, I only seem to be able to call all of them at once.

for(var/mob/S in BattleList)
S.loc=locate(75,425,2)
BattleList -= S

With a series of codes like that I can achieve my goals, except in its current form it calls all mobs not just one...