ID:264044
 
Code:
            if(A.health <= 0)
world<<"[B] has won against [A]!"
B.loc=locate(104,90,1)
B.safe = 1
A.tourny = 0
A.loc=locate(44,186,1)
Tournament_AI()
Entries.Remove(A)//HERE
return


proc
Tournament_AI()
if(Entries.len==1)
Tournament = 0
world<<"<center><B>Tournament over, winner is:<center></b>"
for(var/mob/K in Entries)
world<<"<center><b>[K]</center></b>"
alert("You win 5 Minutes of GM Training!")
K.loc=locate(47,44,1)
spawn(3000)
K.loc=locate(44,186,1)
K<<"<center><b> Staff: Times Up</center></b>"
Entries.Remove(K)
for(var/mob/M in world)
if(M.client)
M.verbs-=typesof(/mob/tournyverb/verb)
M.tourny=0
return
doit
for(var/mob/M in world)
if(M.tourny)
var/A=pick(Entries)
var/B=pick(Entries)

Problem description: Well, The code is meant to be an Automatic Tournament System. It works Relatively fine BUT the one problem with it is that When it goes to the part of the code to pick the winner when there is only one person Left in the list it doesn't pick a winner instead it picks another fight. My belief is the problem lies within the line of Entries.Remove(A) and it doesn't remove A. The line its at is marked by // Here. The Question is, Why doesn't it seem to be working? Thanks for your time Reading this

            if(A.health <= 0)
world<<"[B] has won against [A]!"
B.loc=locate(104,90,1)
B.safe = 1
A.tourny = 0
A.loc=locate(44,186,1)
Tournament_AI()
Entries.Remove(A)
//Create a new list with non-null items
var/list/L = new
for(var/V in Entries)
L+=V
Entries = L
return
In response to Jemai1
Just wondering, But how is that Helping? Can you explain that to me please? I'm confused. From what I see, Your creating a new list Adding the old list to the new list So your practically being left with the Old list. Excuse me if I'm wrong, but that is what i got from it. Please explain?
In response to CK Productions
...
Forget what I posted.
That was useless.

The problem was you called Tournament_AI() before you removed A.


            if(A.health <= 0)
world<<"[B] has won against [A]!"
B.loc=locate(104,90,1)
B.safe = 1
A.tourny = 0
A.loc=locate(44,186,1)
Entries.Remove(A) //Remove first
Tournament_AI()
return
In response to Jemai1
Wow, That was the dumbest thing I've Ever done. *audience applauds* Thanks for the help. *looks around for something to blame* I blame Sleep Deprivation, Yeah thats it! Sleep Deprivation! But besides that, Thanks a-lot!