⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 poa.cpp

📁 Proverbs of Apocrypha (RPG) - Version 2 - Beta 1 ] good !
💻 CPP
📖 第 1 页 / 共 5 页
字号:
#include "poa.hpp"

using namespace std;

/******************************Spell Class Function Definitions*****************************/
void CSpell::assignAll(char tempName[], int tempid, int templvl, int tempmanaCost, int tempminDamage, int tempmaxDamage, int tempminLife, int tempmaxLife, int tempprice){
   strcpy(spellName, tempName);
   id = tempid;
   lvl = templvl;
   manaCost = tempmanaCost;
   minDamage = tempminDamage;
   maxDamage = tempmaxDamage;
   minLife = tempminLife;
   maxLife = tempmaxLife;
   price = tempprice;
}
void CSpell::displayinfo(){
   int minActualD = 0;
   int maxActualD = 0;
   
   clrselection(7, MAPROWSIZE - 1, MENUBOXWIDTH + 1, COLSIZE - 1);
   
   centerText("Detailed Spell Information", 7, MENUBOXWIDTH, COLSIZE);
   
   gotoxy(9, MENUBOXWIDTH + 2);
   cout<<"Spell Name: "<<getname()<<flush;
   gotoxy(11, MENUBOXWIDTH + 2);
   cout<<"Spell Class: "<<"Not Implemented Yet"<<flush;
   gotoxy(12, MENUBOXWIDTH + 2);
   cout<<"Spell Level: "<<getlvl()<<flush;
   gotoxy(15, MENUBOXWIDTH + 2);
   cout<<"Mana Cost: "<<getmanaCost()<<flush;
   
   if(getminLife() == 0){
      mainchar.calctotalspelldamage(&minActualD, &maxActualD, getminDamage(), getmaxDamage());
      
      gotoxy(17, MENUBOXWIDTH + 2);
      cout<<"Base Damage: "<<getminDamage()<<" - "<<getmaxDamage()<<flush;
      gotoxy(19, MENUBOXWIDTH + 2);
      cout<<"Actual Damage: "<<minActualD<<" - "<<maxActualD<<flush;
   }
   else{
      gotoxy(17, MENUBOXWIDTH + 2);
      cout<<"Minimum Life Restore: "<<getminLife()<<flush;
      gotoxy(19, MENUBOXWIDTH + 2);
      cout<<"Maximum Life Restore: "<<getmaxLife()<<flush;
   }
}
void CSpell::displaybattleinfo(){
   int minD = 0;
   int maxD = 0;
   
   clrselection(3, MAPROWSIZE - 15, COLSIZE - 29, COLSIZE - 1);
   
   centerText(spellName, 4, COLSIZE - 30, COLSIZE);
   centerText("Spell Class: In Progress", 6, COLSIZE - 30, COLSIZE);
   centerText("Spell Level: ", 8, COLSIZE - 30, COLSIZE, GREY, 1, IntStr(lvl).str);
   centerText("Mana Cost: ", 10, COLSIZE - 30, COLSIZE, GREY, 1, IntStr(manaCost).str);
   
   mainchar.calctotalspelldamage(&minD, &maxD, minDamage, maxDamage);
   
   if(getminLife() == 0){
      centerText("Actual Damage: ", 12, COLSIZE - 30, COLSIZE, GREY, 3, IntStr(minD).str, " - ", IntStr(maxD).str);
   }
   else{
      centerText("Life Restore: ", 12, COLSIZE - 30, COLSIZE, GREY, 3, IntStr(minLife).str, " - ", IntStr(maxLife).str);
   }  
}   


/******************************Bonus Class Function Definitions*****************************/
void CBonus::assignAll(char tempName[], int tempid, int temphp, int tempdamage, int tempdefense, int tempmana, int tempstr, int tempdex, int tempvit, int tempenergy){
   strcpy(bonusName, tempName);
   id = tempid;
   hp = temphp;
   damage = tempdamage;
   defense = tempdefense;
   mana = tempmana;
   str = tempstr;
   dex = tempdex;
   vit = tempvit;
   energy = tempenergy;
}


/******************************Item Class Function Definitions*****************************/
void CItem::assignAll(char tempName[], char tempClass[], int tempid, int templvl, int tempwepid, int tempsid, int tempminD, int tempmaxD, int tempdef, int tempprice){
   strcpy(itemName, tempName);
   strcpy(itemClass, tempClass);
   id = tempid;
   lvl = templvl;
   wepid = tempwepid;
   sid = tempsid;
   minDamage = tempminD;
   maxDamage = tempmaxD;
   defense = tempdef;
   price = tempprice;
}
void CItem::displayinfo(){
   int counter;
   int minActualD = 0;
   int maxActualD = 0;
   int place;
   
   clrselection(7, MAPROWSIZE - 1, MENUBOXWIDTH + 1, COLSIZE - 1);
   
   centerText("Detailed Item Information", 7, MENUBOXWIDTH, COLSIZE);
   
   gotoxy(9, MENUBOXWIDTH + 2);
   cout<<"Item Name: "<<getname()<<flush;
   gotoxy(11, MENUBOXWIDTH + 2);
   cout<<"Item Class: "<<getclass()<<flush;
   gotoxy(13, MENUBOXWIDTH + 2);
   cout<<"Item Level: "<<getlvl()<<flush;
   
   counter = 15;
   if(getdefense() == 0){
      place = searchforid("Items", getid());
      mainchar.calctotalmeleedamage(&minActualD, &maxActualD, allItems[place]);
      
      gotoxy(counter++, MENUBOXWIDTH + 2);
      cout<<"Base Damage: "<<getminDamage()<<" - "<<getmaxDamage()<<flush;
      gotoxy(counter++, MENUBOXWIDTH + 2);
      cout<<"Actual Damage: "<<minActualD<<" - "<<maxActualD<<flush;
   }
   else{
      gotoxy(counter++, MENUBOXWIDTH + 2);
      cout<<"Defense: "<<getdefense()<<flush;
   }

   counter = 4;
   for(int indexBonuses = 0; indexBonuses < MAXBONUSESPERITEM; indexBonuses++){
      if(getbonuses(indexBonuses).getid() != 0){
         gotoxy(counter++, MENUBOXWIDTH + 20);
         cout<<"Bonus Name: "<<getbonuses(indexBonuses).getname()<<flush;
         if(getbonuses(indexBonuses).gethp() != 0){
            gotoxy(counter++, MENUBOXWIDTH + 20);
            cout<<"+"<<getbonuses(indexBonuses).gethp()<<" Max Hitpoints"<<flush;
         }   
         if(getbonuses(indexBonuses).getmana() != 0){
            gotoxy(counter++, MENUBOXWIDTH + 20);
            cout<<"+"<<getbonuses(indexBonuses).getmana()<<" Max Mana"<<flush;
         }
         if(getbonuses(indexBonuses).getdefense() != 0){
            gotoxy(counter++, MENUBOXWIDTH + 20);
            cout<<"+"<<getbonuses(indexBonuses).getdefense()<<" Defense"<<flush;
         }
         if(getbonuses(indexBonuses).getstr() != 0){
            gotoxy(counter++, MENUBOXWIDTH + 20);
            cout<<"+"<<getbonuses(indexBonuses).getstr()<<" Strength"<<flush;
         } 
         if(getbonuses(indexBonuses).getdex() != 0){
            gotoxy(counter++, MENUBOXWIDTH + 20);
            cout<<"+"<<getbonuses(indexBonuses).getdex()<<" Dexterity"<<flush;
         } 
         if(getbonuses(indexBonuses).getvit() != 0){
            gotoxy(counter++, MENUBOXWIDTH + 20);
            cout<<"+"<<getbonuses(indexBonuses).getvit()<<" Vitality"<<flush;
         }  
         if(getbonuses(indexBonuses).getenergy() != 0){
            gotoxy(counter++, MENUBOXWIDTH + 20);
            cout<<"+"<<getbonuses(indexBonuses).getenergy()<<" Energy"<<flush;
         }  
         if(getbonuses(indexBonuses).getspells(0).getid() != 0){
            gotoxy(counter++, MENUBOXWIDTH + 20);
            cout<<"Spell Name: "<<getbonuses(indexBonuses).getspells(0).getname()<<flush;
               gotoxy(counter++, MENUBOXWIDTH + 20);
               cout<<"Level of Spell: "<<getbonuses(indexBonuses).getspells(0).getlvl()<<flush;
               gotoxy(counter++, MENUBOXWIDTH + 20);
               cout<<"Mana Cost: "<<getbonuses(indexBonuses).getspells(0).getmanaCost()<<flush;
               if(getbonuses(indexBonuses).getspells(0).getminLife() == 0){
                  gotoxy(counter++, MENUBOXWIDTH + 20);
                  cout<<"Minimum Base Damage: "<<getbonuses(indexBonuses).getspells(0).getminDamage()<<flush;
                  gotoxy(counter++, MENUBOXWIDTH + 20);
                  cout<<"Maximum Base Damage: "<<getbonuses(indexBonuses).getspells(0).getmaxDamage()<<flush;
               }
               else{
                  gotoxy(counter++, MENUBOXWIDTH + 20);
                  cout<<"Minimum Life Restore: "<<getbonuses(indexBonuses).getspells(0).getminLife()<<flush;
                  gotoxy(counter++, MENUBOXWIDTH + 20);
                  cout<<"Maximum Life Restore: "<<getbonuses(indexBonuses).getspells(0).getmaxLife()<<flush;
               }
         }
      }
      counter++;
   }   
} 


/******************************Potion Class Function Definitions*****************************/
void CPotion::assignAll(char tempName[], int tempid, int temphealormana, int temphpRestore, int tempmanaRestore, int tempprice){
   strcpy(potionName, tempName);
   id = tempid;
   healormana = temphealormana;
   hpRestore = temphpRestore;
   manaRestore = tempmanaRestore;
   price = tempprice;
}
void CPotion::displaybattleinfo(){
   clrselection(3, MAPROWSIZE - 15, COLSIZE - 29, COLSIZE - 1);
   
   centerText(potionName, 5, COLSIZE - 30, COLSIZE);
   
   if(healormana == 1){
      centerText("Type: Healing", 7, COLSIZE - 30, COLSIZE);
      centerText("Restores ", 9, COLSIZE - 30, COLSIZE, GREY, 2, IntStr(hpRestore).str, " Hitpoints");
   }
   else{
      centerText("Type: Mana", 7, COLSIZE - 30, COLSIZE);
      centerText("Restores ", 9, COLSIZE - 30, COLSIZE, GREY, 2, IntStr(manaRestore).str, " Mana");
   }      
}


/******************************Monster Class Function Definitions*****************************/
void CMonster::assignAll(char tempName[], int tempid, int templvl, int temphp, int tempminDamage, int tempmaxDamage, int tempdefense, int tempexp){
   strcpy(monsterName, tempName);
   id = tempid;
   lvl = templvl;
   hp = temphp;
   minDamage = tempminDamage;
   maxDamage = tempmaxDamage;
   defense = tempdefense;
   exp = tempexp;
}
void CMonster::displayinfo(){
   clrline(MAPROWSIZE - 12, COLSIZE - 35 + 8, COLSIZE - 35 + 10);
   clrline(MAPROWSIZE - 10, COLSIZE - 35 + 12, COLSIZE - 35 + 22);
   clrline(MAPROWSIZE - 8, COLSIZE - 35 + 9, COLSIZE - 35 + 20);
   clrline(MAPROWSIZE - 6, COLSIZE - 35 + 17, COLSIZE - 35 + 22);
   
   gotoxy(MAPROWSIZE - 12, COLSIZE - 35 + 8);  cout<<getlvl()<<flush;
   gotoxy(MAPROWSIZE - 10, COLSIZE - 35 + 12);  cout<<gethp()<<"/"<<gethp()<<flush;
   gotoxy(MAPROWSIZE - 8, COLSIZE - 35 + 9);  cout<<getminD()<<" - "<<getmaxD()<<flush;
   gotoxy(MAPROWSIZE - 6, COLSIZE - 35 + 17);  cout<<getdefense()<<flush;
}


/******************************Character Class Function Definitions*****************************/
int CCharacter::gettotal(char category[]){
   int counter = 0;
   
   if(strcmp(category, "weapons") == 0){
      if(getwep().getid() != 0)
         counter++;
      for(int z = 0; z < MAXITEMSPERINV; z++){
         if(getinv(z).getwepid() == 1)
            counter++;
      }
   }   
   else if(strcmp(category, "shields") == 0){
      if(getshield().getid() != 0)
         counter++;
      for(int z = 0; z < MAXITEMSPERINV; z++){
         if(strcmp(getinv(z).getclass(), "shield") == 0)
            counter++;
      }
   }   
   else if(strcmp(category, "armor") == 0){
      if(getarmor().getid() != 0)
         counter++;
      for(int z = 0; z < MAXITEMSPERINV; z++){
         if(strcmp(getinv(z).getclass(), "armor") == 0)
            counter++;
      }
   }   
   else if(strcmp(category, "helms") == 0){
      if(gethelm().getid() != 0)
         counter++;
      for(int z = 0; z < MAXITEMSPERINV; z++){
         if(strcmp(getinv(z).getclass(), "helm") == 0)
            counter++;
      }
   }   
   else
      Error("Error:  CCharacter: category Not Recognized");
      
   return(counter);
}   
void CCharacter::assembleChar(char charName[], char charClass[], int nexp, int ngold, int nlvl, int nhp, int nhpMax, int nmana, int nmanaMax, int nstr, int ndex, int nvit, int nenergy, int wep_id, int helm_id, int armor_id, int shield_id, int spell_ids[], int inv_ids[], int pot_ids[], int ntileY, int ntileX){
   int temp;
   int index;
   
   strcpy(characterName, charName);
   strcpy(characterClass, charClass);
   
   exp = nexp;
   gold = ngold;
   lvl = nlvl;
   hp = nhp;
   hpMax = nhpMax;
   mana = nmana;
   manaMax = nmanaMax;
   str = nstr;
   dex = ndex;
   vit = nvit;
   energy = nenergy;  
   
   temp = searchforid("Items", wep_id);
   weapon = allItems[temp];
   
   temp = searchforid("Items", helm_id);
   helm = allItems[temp];
   
   temp = searchforid("Items", armor_id);
   armor = allItems[temp];
   
   temp = searchforid("Items", shield_id);
   shield = allItems[temp];
   
   index = 0;
   for(int indexSpells = 0; indexSpells < MAXSPELLS; indexSpells++){
      temp = searchforid("Spells", spell_ids[index]);
      spells[index++] = allSpells[temp];
   }

   index = 0;
   for(int indexItems = 0; indexItems < MAXITEMSPERINV; indexItems++){
      temp = searchforid("Items", inv_ids[index]);
      inv[index++] = allItems[temp];
   }

   index = 0;
   for(int indexPots = 0; indexPots < MAXPOTS; indexPots++){
      temp = searchforid("Potions", pot_ids[index]);
      pots[index++] = allPotions[temp];
   }

   tileY = ntileY;
   tileX = ntileX;
}
void CCharacter::addexp(int amt, int lootedMoney){
   int newstats;
   int counter = 0;
   int nextstat;
   
   clrnon_border();
   exp += amt;
   
   if(mainchar.getlvl() == TOTALLEVELS){
      newtop("You have Looted ", 2, IntStr(lootedMoney).str, " but gained no Experience since you are at the Max Level");
   }
   else{
      while(exptonLvl() <= 0){
         lvl++;
         centerText("You gained a Level...you are now level ", 4, 0, COLSIZE, 7, 1, IntStr(lvl).str);
         centerText("For being a ", 6, 0, COLSIZE, 7, 2, characterClass, " you get:");
         switch(characterClass[0]){
            case 'B':
               centerText("+2 Strength", 8);
               centerText("+12 Max Hitpoints", 9);
               centerText("+3 Max Mana", 10);
               str += 2;
               hpMax += 12;
               manaMax += 3;
               hp = hpMax;
               mana = manaMax;
               counter = 12;
               break;
            case 'K':
               centerText("+1 Strength", 8);
               centerText("+1 Dexterity", 9);
               centerText("+8 Max Hitpoints", 10);
               centerText("+7 Max Mana", 11);
               str += 1;
               dex += 1;
               hpMax += 8;
               manaMax += 7;
               hp = hpMax;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -