X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FAwards.cpp;h=ea8a610c2447937686b666b98218917f0b3448d3;hb=cd043e3f9e26c2b3406b40a354c2840941e9db7f;hp=726eaec8d1d9cdbb5696bb818b014e39b40d1c12;hpb=46cff1de1e828cb8c04a5dc5377bc07baae57858;p=lugaru.git diff --git a/Source/Awards.cpp b/Source/Awards.cpp index 726eaec..ea8a610 100644 --- a/Source/Awards.cpp +++ b/Source/Awards.cpp @@ -3,20 +3,18 @@ Copyright (C) 2010 - Lugaru authors This file is part of Lugaru. -Lugaru is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. +Lugaru is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. -This program is distributed in the hope that it will be useful, +Lugaru is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +along with Lugaru. If not, see . */ #include "Awards.h" @@ -30,6 +28,18 @@ float startbonustotal; float bonustime; float bonusnum[100]; +const char *bonus_names[bonus_count] = { +#define DECLARE_BONUS(id, name, ...) name, +#include "Bonuses.def" +#undef DECLARE_BONUS +}; + +const char *award_names[award_count] = { +#define DECLARE_AWARD(id, name) name, +#include "Awards.def" +#undef DECLARE_AWARD +}; + static const int bonus_values[bonus_count] = { #define DECLARE_BONUS(id, name, value, ...) value, #include "Bonuses.def" @@ -39,11 +49,11 @@ static const int bonus_values[bonus_count] = { void award_bonus(int playerid, int bonusid, int alt_value) { - if (playerid != 0) - return; - bonus = bonusid; - bonustime = 0; - bonusvalue = alt_value ? alt_value : bonus_values[bonusid]; + if (playerid != 0) + return; + bonus = bonusid; + bonustime = 0; + bonusvalue = alt_value ? alt_value : bonus_values[bonusid]; } // FIXME: make these per-player @@ -67,78 +77,81 @@ int maxalarmed; int award_awards(int *awards) { - int numawards = 0, i; - if(damagetaken==0&&player[0].bloodloss==0){ - awards[numawards]=awardflawless; - numawards++; - } - bool alldead = true; - for(i=1;i0){ - awards[numawards]=awardbojutsu; - numawards++; - } - if(numattacks==numswordattack&&numattacks>0){ - awards[numawards]=awardswordsman; - numawards++; - } - if(numattacks==numknifeattack&&numattacks>0){ - awards[numawards]=awardknifefighter; - numawards++; - } - if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.size()>0){ - awards[numawards]=awardkungfu; - numawards++; - } - if(numescaped>0){ - awards[numawards]=awardevasion; - numawards++; - } - if(numflipfail==0&&numflipped+numwallflipped*2>20){ - awards[numawards]=awardacrobat; - numawards++; - } - if(numthrowkill==numplayers-1){ - awards[numawards]=awardlongrange; - numawards++; - } - alldead=1; - for(i=1;i0&&alldead){ - awards[numawards]=awardbrutal; - numawards++; - } - if(numreversals>((float)numattacks)*.8&&numreversals>3){ - awards[numawards]=awardaikido; - numawards++; - } - if(maxalarmed==1&&numplayers>2){ - awards[numawards]=awardstrategy; - numawards++; - } - if(numflipfail>3){ - awards[numawards]=awardklutz; - numawards++; - } - return numawards; + int numawards = 0; + if (damagetaken == 0 && Person::players[0]->bloodloss == 0) { + awards[numawards] = awardflawless; + numawards++; + } + bool alldead = true; + for (unsigned i = 1; i < Person::players.size(); i++) { + if (Person::players[i]->dead != 2) + alldead = 0; + } + if (alldead) { + awards[numawards] = awardalldead; + numawards++; + } + alldead = 1; + for (unsigned i = 1; i < Person::players.size(); i++) { + if (Person::players[i]->dead != 1) + alldead = 0; + } + if (alldead) { + awards[numawards] = awardnodead; + numawards++; + } + if (numresponded == 0 && !numthrowkill) { + awards[numawards] = awardstealth; + numawards++; + } + if (numattacks == numstaffattack && numattacks > 0) { + awards[numawards] = awardbojutsu; + numawards++; + } + if (numattacks == numswordattack && numattacks > 0) { + awards[numawards] = awardswordsman; + numawards++; + } + if (numattacks == numknifeattack && numattacks > 0) { + awards[numawards] = awardknifefighter; + numawards++; + } + if (numattacks == numunarmedattack && numthrowkill == 0 && weapons.size() > 0) { + awards[numawards] = awardkungfu; + numawards++; + } + if (numescaped > 0) { + awards[numawards] = awardevasion; + numawards++; + } + if (numflipfail == 0 && numflipped + numwallflipped * 2 > 20) { + awards[numawards] = awardacrobat; + numawards++; + } + if (numthrowkill == (int(Person::players.size()) - 1)) { + awards[numawards] = awardlongrange; + numawards++; + } + alldead = 1; + for (unsigned i = 1; i < Person::players.size(); i++) { + if (Person::players[i]->dead != 2) + alldead = 0; + } + if (numafterkill > 0 && alldead) { + awards[numawards] = awardbrutal; + numawards++; + } + if (numreversals > ((float)numattacks)*.8 && numreversals > 3) { + awards[numawards] = awardaikido; + numawards++; + } + if (maxalarmed == 1 && Person::players.size() > 2) { + awards[numawards] = awardstrategy; + numawards++; + } + if (numflipfail > 3) { + awards[numawards] = awardklutz; + numawards++; + } + return numawards; }