Actualmente estoy trabajando en un servidor de emulación para un juego basado en cliente flash, que tiene un "sistema de mascotas", y me preguntaba si habría una forma más sencilla de verificar el nivel de mascotas especificadas.Método más simple/más eficiente de anidar si ... ¿otro flujo?
código actual:
public int Level
{
get
{
if (Expirience > 100) // Level 2
{
if (Expirience > 200) // Level 3
{
if (Expirience > 400) // Level 4 - Unsure of Goal
{
if (Expirience > 600) // Level 5 - Unsure of Goal
{
if (Expirience > 1000) // Level 6
{
if (Expirience > 1300) // Level 7
{
if (Expirience > 1800) // Level 8
{
if (Expirience > 2400) // Level 9
{
if (Expirience > 3200) // Level 10
{
if (Expirience > 4300) // Level 11
{
if (Expirience > 7200) // Level 12 - Unsure of Goal
{
if (Expirience > 8500) // Level 13 - Unsure of Goal
{
if (Expirience > 10100) // Level 14
{
if (Expirience > 13300) // Level 15
{
if (Expirience > 17500) // Level 16
{
if (Expirience > 23000) // Level 17
{
return 17; // Bored
}
return 16;
}
return 15;
}
return 14;
}
return 13;
}
return 12;
}
return 11;
}
return 10;
}
return 9;
}
return 8;
}
return 7;
}
return 6;
}
return 5;
}
return 4;
}
return 3;
}
return 2;
}
return 1;
}
}
Sí, soy consciente de que he experiencia misspelt, que había cometido el error en una función anterior y no había tenido tiempo de actualizar todo.
No hay manera de que esto no es una cuestión broma. –
En caso de que no lo sepa (no diciendo que no está ... simplemente tratando de ser útil), "actualizar todo" no es un proceso oneroso. Haga clic con el botón derecho en "Expirience"> Refactorizar> Cambiar nombre. Bueno para ir ... principalmente (las vistas no se actualizarán). –
@George - o alguien lee TDWTF para las muestras de código ... – GalacticCowboy