Skip to content

Instantly share code, notes, and snippets.

@hcarreras
Created November 23, 2013 17:44
Show Gist options
  • Save hcarreras/7617647 to your computer and use it in GitHub Desktop.
Save hcarreras/7617647 to your computer and use it in GitHub Desktop.
compara(name1, asked_clues1, name2, clues2)
{
NSMutableString *respuesta;
bool attribute? = false;
Clues clueA, clueB;
for (clueA in asked_clues1)
for(clueB in clues2)
if(clueA.attr == clueB.attr){
attribute? = true;
if(clueB.value == clueB.value){
//he acertado, siguiente pista
respuesta = nil;
}
else{
//Valor incorrecto. responder con value
respuesta = [[NSMutableString alloc] initWithString:name2];
[respuesta appendString:clueB.question;
}
}
}
}
//No hay ninguno con la misma propiedad, simplemente devolvemos
//que ese objeto no hace la última pista
if(!attribute?){
Clue clue_aux;
clue_aux = [[Clue alloc];
clue_aux = [asked_clues1 objectAtIndex: [array count]];
respuesta = [[NSMutableString alloc] initWithString:name2];
[respuesta appendString:@" no "];
[respuesta appendString:clue_aux.question]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment