1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
gameObjectType cave[TOTAL_ROWS][TOTAL_COLS]; // the cave--a two dimensional array
char board[TOTAL_ROWS + 3][TOTAL_COLS + 3] = // the game board--a two dimensional array
{
{MT,MT,'A','B','C','D','E','F','G','H','I','J','K','L','M','N', MT},
{MT,ULC,HB, HB, HB, HB, HB, HB, HB, HB, HB, HB, HB, HB, HB, HB, URC},
{'A',VB,MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, VB},
{'B',VB,MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, VB},
{'C',VB,MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, VB},
{'D',VB,MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, VB},
{'E',VB,MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, VB},
{'F',VB,MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, VB},
{'G',VB,MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, VB},
{'H',VB,MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, VB},
{'I',VB,MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, VB},
{'J',VB,MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, MT, VB},
{MT,LLC,HB, HB, HB, HB, HB, HB, HB, HB, HB, HB, HB, HB, HB, HB, LRC}
};
// <WK7 status=permanent>
//...Add Thief in any empty location
thief.row = rand() %1 + 4; // update thief's row
thief.column = rand() %8 + 2;
cave[thief.row][thief.column] = THIEF;
// </WK7>
// <WK7 status=permanent>
// process thief
void processThief(bool thiefPause, gameObjectType cave[TOTAL_ROWS][TOTAL_COLS], gameObject& thief, int& thiefMoveCounter,
playerObject& player, string& msg, bool& gameOver, int& killedThiefValue, int& killThiefValue, bool& movePlayer,
gameObjectType& hold, char board[TOTAL_ROWS + 3][TOTAL_COLS + 3])
{
int row = 0, column = 0;
// store last 2 thief moves
//thief.qTwoBackPosition = thief.qOneBackPosition;
//thief.qOneBackPosition = thief.position;
if (thiefPause)
{
// Thief paused. Check if Thief starts moving again
if (rand() %3 == 1)
{
thiefPause = false;
}
}
else
{
// Move Thief
thiefMoveCounter = (++thiefMoveCounter) %2;
row = thief.row;
column = thief.column;
switch (thiefMoveCounter)
{
case 0:
column--;
break;
case 1:
row++;
break;
case 2:
row--;
break;
case 3:
column++;
break;
case 4:
column--;
break;
case 5:
row++;
break;
case 6:
row--;
break;
case 7:
column++;
break;
default:
break;
}
// Check for events
// If player found
if (cave[row][column] == PLAYER)
{
msg = "The thief has found you";
//........Resolve combat
//gameOver = resolveCombat(player, msg, movePlayer, cave, row, column, board);
//if (player.hasWeapon)
//{
//msg = "The thief stole your weapon.";
//monster.isFound = true;
//}
//else
//{
//gameOver = false;
//player.alive = true;
//msg = "You felt the slight breeze of something else.";
// when player has no weapon and thief is found
// thief will move back two spaces
// interacting message will display
//thief.position = thief.qOneBackPosition;
//cave[thief.position.row][thief.position.column] = EMPTY; //updates position information
//cave[thief.position.row][thief.position.column] = PLAYER;
//board[thief.position.row + 2][thief.position.column + 2] = MT; //clear the screen where player was
// set up to move thief back another space
//row = thief.qTwoBackPosition.row;
//column = thief.qTwoBackPosition.column;
//return false;
//}
}
// Check for events
// If monster found
//if (cave[row][column] == MONSTER)
//{
//msg = "The thief has found the monster";
// Resolve combat
//gameOver = resolveCombat(thief, monster, msg, monsterPause, thiefPause, cave, row, column, board);
//if (thief.hasWeapon)
//{
//msg = "The thief found the monster and monster was slain.";
//monster.isFound = true;
//}
//else
//{
//gameOver = true;
//player.alive = false;
//msg = "The monster found you and you have died";
//}
//}
else
{
// Move Thief
cave[thief.row][thief.column] = hold; // reveal what is under the monster <bug fix in week 6>
//cave[monster.row][monster.column] = EMPTY; // clear the cave location <creates bug>
board[thief.row + 4][thief.column + 4] = MT; // clear the screen behind monster
//hold = cave[row][column]; // save what the monster is about to move over <bug fix in week 6>
thief.row = row; // update thief's row
thief.column = column; // update thief's column
cave[row][column] = THIEF; // change thief's location in the cave
}
}
}
// </WK7>
|