Basics of benching/unbenching for players.

This commit is contained in:
Martin Haye 2016-11-10 08:40:50 -08:00
parent a4421e9882
commit 1f55dea477
8 changed files with 128 additions and 3 deletions

View File

@ -122,6 +122,8 @@
<block type="interaction_add_player"></block>
<block type="interaction_remove_player"></block>
<block type="interaction_has_player"></block>
<block type="interaction_bench_player"></block>
<block type="interaction_unbench_player"></block>
<block type="interaction_get_stat"></block>
<block type="interaction_increase_stat"></block>
<block type="interaction_decrease_stat"></block>

View File

@ -699,6 +699,30 @@ if (typeof Mythos === "undefined") {
this.setTooltip('Check if party has a given player');
}
};
Blockly.Blocks['interaction_bench_player'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);
this.setColour(54);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.appendDummyInput()
.appendField("Send a player to the bench");
this.setOutput(false);
this.setTooltip('Send a player to the bench (selected by user)');
}
};
Blockly.Blocks['interaction_unbench_player'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);
this.setColour(54);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.appendDummyInput()
.appendField("Retrieve a benched player");
this.setOutput(false);
this.setTooltip('Retrieve a benched player (selected by user)');
}
};
Blockly.Blocks['interaction_get_stat'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);

View File

@ -2999,6 +2999,10 @@ end
packAddPlayer(blk); break
case 'interaction_remove_player':
packRemovePlayer(blk); break
case 'interaction_bench_player':
packBenchPlayer(blk); break
case 'interaction_unbench_player':
packUnbenchPlayer(blk); break
case 'interaction_increase_stat':
case 'interaction_decrease_stat':
packChangeStat(blk); break
@ -3099,6 +3103,18 @@ end
outIndented("removePlayerFromParty(${escapeString(name)})\n")
}
def packBenchPlayer(blk)
{
assert blk.field.size() == 0
outIndented("benchPlayer()\n")
}
def packUnbenchPlayer(blk)
{
assert blk.field.size() == 0
outIndented("unbenchPlayer()\n")
}
def nameToStat(name) {
def lcName = name.toLowerCase().trim()
assert lcName in stats : "Unrecognized stat '$name'"

View File

@ -2403,6 +2403,10 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def addPlayerToParty(playerFuncNum)
word p
if countList(global=>p_players) == MAX_PARTY
displayStr("Party too large.")
return
fin
p = createAndAddUnique(MODULE_GEN_PLAYERS, playerFuncNum, @global=>p_players)
p->b_playerFlags = p->b_playerFlags | PLAYER_FLAG_NPC
needShowParty = TRUE
@ -2529,6 +2533,18 @@ export def setIntimateMode(enable)
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def benchPlayer()
loadEngine(MODULE_PARTY)=>party_benchPlayer()
returnFromEngine()
end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def unbenchPlayer()
loadEngine(MODULE_PARTY)=>party_unbenchPlayer()
returnFromEngine()
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def startGame(ask)
word p_module

View File

@ -68,3 +68,5 @@ const EVENT_ENTER = 1
const EVENT_LEAVE = 2
const EVENT_USE_ITEM = 3
// Party size
const MAX_PARTY = 3

View File

@ -39,8 +39,8 @@ word global
// Exported functions go here. First a predef for each one, then a table with function pointers
// in the same order as the constants are defined in the the header.
predef _party_doPlayerSheet
word[] funcTbl = @_party_doPlayerSheet
predef _party_doPlayerSheet, _party_benchPlayer, _party_unbenchPlayer
word[] funcTbl = @_party_doPlayerSheet, @_party_benchPlayer, @_party_unbenchPlayer
// Other global variables here
@ -403,6 +403,68 @@ def _party_doPlayerSheet(num)
until 0
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Display a list of NPCs and allow user to select one.
def selectPlayer(players)
byte n_item
word player
// First, display the list
player = players
n_item = 0
while player
if player->b_playerFlags & PLAYER_FLAG_NPC; continue; fin
displayf1("\n%c)", 'A' + n_item)
rawDisplayStr("^T018")
displayStr(player=>s_name)
n_item++
player = player=>p_nextObj
loop
if !n_item
displayStr("No applicable characters.")
return NULL
fin
// Then get a selection
rawDisplayStr("\n^T032Which character?")
n_item = getUpperKey() - 'A'
player = players
while n_item > 0 and player
player = player=>p_nextObj
n_item--
loop
return player
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Allow user to select an active player, and put them on the bench
def _party_benchPlayer()
word player
player = selectPlayer(global=>p_players)
if player
removeFromList(@global=>p_players, player)
addToList(@global=>p_benched, player)
displayStr("\nDone.")
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Allow user to select a benched player, and put them on the bench
def _party_unbenchPlayer()
word player
if countList(global=>p_players) == MAX_PARTY
displayStr("Party too large.")
return
fin
player = selectPlayer(global=>p_benched)
if player
removeFromList(@global=>p_benched, player)
addToList(@global=>p_players, player)
displayStr("\nDone.")
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Boilerplate module initialization code
global = getGlobals()

View File

@ -8,5 +8,7 @@
// governing permissions and limitations under the License.
///////////////////////////////////////////////////////////////////////////////////////////////////
// Each module-exported function needs its own constant, 0..n
// Each module-exported function needs its own constant, 0..n (multiples of 2)
const party_showPlayerSheet = 0
const party_benchPlayer = 2
const party_unbenchPlayer = 4

View File

@ -15,6 +15,7 @@ const TYPE_GLOBAL = $80
struc Global
byte t_type
word p_players
word p_benched
word p_enemyGroups
word p_combatFirst
word p_encounterZones