mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-02-20 21:29:13 +00:00
Working on comparison shopper.
This commit is contained in:
parent
2e779c5028
commit
7622f4e41b
@ -16,6 +16,9 @@ include "gen_items.plh"
|
||||
|
||||
const PAGE_SIZE = 14 // (183-10)/9 lines, minus 5 lines for header/footer
|
||||
|
||||
const STATS_COL_1 = 60
|
||||
const STATS_COL_2 = 120
|
||||
|
||||
// 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 header.
|
||||
predef _buyFromStore, _sellToStore
|
||||
@ -160,17 +163,186 @@ def displayBuyPage(pItemTbl, markupRatio, pageNum, nPages)
|
||||
return itemNum
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def tabTo(cursorX)
|
||||
rawDisplayf1("^T%D", cursorX)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def formatDice(encoded)
|
||||
byte nDice, dieSize, add
|
||||
nDice = encoded >> 12
|
||||
dieSize = (encoded >> 8) & $F
|
||||
add = encoded & $F
|
||||
rawDisplayf2("%dd%d", nDice, dieSize)
|
||||
if add; rawDisplayf1("+%d", add); fin
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def formatNum(num)
|
||||
rawDisplayf1("%d", num)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def formatStr(str)
|
||||
rawDisplayf1("%s", str)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def formatAttack(code)
|
||||
if !code; return; fin
|
||||
if code == 1
|
||||
rawDisplayStr("single")
|
||||
elsif code == 2
|
||||
rawDisplayStr("double")
|
||||
else
|
||||
rawDisplayf1("%d-shot", code)
|
||||
fin
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def byteField(pItem, field)
|
||||
if pItem
|
||||
return ^(pItem + field)
|
||||
else
|
||||
return 0
|
||||
fin
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def wordField(pItem, field)
|
||||
if pItem
|
||||
return *(pItem + field)
|
||||
else
|
||||
return 0
|
||||
fin
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def displayTwoCol(fieldName, pItem1, pItem2, field, fieldFunc, formatFunc)
|
||||
word val1, val2
|
||||
val1 = fieldFunc(pItem1, field)
|
||||
val2 = fieldFunc(pItem2, field)
|
||||
if val1 or val2
|
||||
rawDisplayf1("\n%s", fieldName)
|
||||
if val1; tabTo(STATS_COL_1); formatFunc(val1); fin
|
||||
if val2; tabTo(STATS_COL_2); formatFunc(val2); fin
|
||||
fin
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def displayWeaponStats(pItem1, pItem2)
|
||||
displayTwoCol("Uses", pItem1, pItem2, b_maxUses, @byteField, @formatNum)
|
||||
displayTwoCol("Ammo", pItem1, pItem2, s_ammoKind, @wordField, @formatStr)
|
||||
displayTwoCol("Clip", pItem1, pItem2, b_clipSize, @byteField, @formatNum)
|
||||
displayTwoCol("Melee", pItem1, pItem2, r_meleeDmg, @wordField, @formatDice)
|
||||
displayTwoCol("Proj", pItem1, pItem2, r_projectileDmg, @wordField, @formatDice)
|
||||
displayTwoCol("Attck", pItem1, pItem2, ba_attacks+0, @byteField, @formatAttack)
|
||||
displayTwoCol("Att 2", pItem1, pItem2, ba_attacks+1, @byteField, @formatAttack)
|
||||
displayTwoCol("Att 3", pItem1, pItem2, ba_attacks+2, @byteField, @formatAttack)
|
||||
displayTwoCol("Range", pItem1, pItem2, b_weaponRange, @byteField, @formatNum)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def displayArmorStats(pItem1, pItem2)
|
||||
displayTwoCol("Uses", pItem1, pItem2, b_maxUses, @byteField, @formatNum)
|
||||
displayTwoCol("Protec", pItem1, pItem2, b_armorValue, @byteField, @formatNum)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def displayStuffStats(pItem1, pItem2)
|
||||
// Nothing special
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def displayItemStats(pItem1, price, pItem2)
|
||||
word pMod1, pMod2
|
||||
|
||||
// First, show the item type and name
|
||||
when pItem1->t_type
|
||||
is TYPE_ITEM; rawDisplayStr("\nItem"); break
|
||||
is TYPE_WEAPON; rawDisplayStr("\nWeapon"); break
|
||||
is TYPE_ARMOR; rawDisplayStr("\nArmor"); break
|
||||
is TYPE_STUFF; rawDisplayStr("\nSupply"); break
|
||||
otherwise fatal("tItem")
|
||||
wend
|
||||
tabTo(STATS_COL_1); displayItemName(pItem1)
|
||||
if pItem2
|
||||
if pItem1->t_type <> pItem2->t_type; fatal("tMatch"); fin
|
||||
tabTo(STATS_COL_2); displayItemName(pItem2)
|
||||
fin
|
||||
|
||||
// Type-specific attributes
|
||||
when pItem1->t_type
|
||||
is TYPE_WEAPON; displayWeaponStats(pItem1, pItem2); break
|
||||
is TYPE_ARMOR; displayArmorStats(pItem1, pItem2); break
|
||||
is TYPE_STUFF; displayStuffStats(pItem1, pItem2); break
|
||||
wend
|
||||
|
||||
// If either item has modifiers, show them
|
||||
pMod1 = pItem1=>p_modifiers
|
||||
pMod2 = NULL
|
||||
if pItem2; pItem2=>p_modifiers; fin
|
||||
if pMod1 or pMod2
|
||||
rawDisplayStr("\nSpecial:")
|
||||
while pMod1 or pMod2
|
||||
if pMod1
|
||||
rawDisplayf3("^T%D%d %s", STATS_COL_1, pMod1=>w_modValue, pMod1=>s_name)
|
||||
pMod1 = pMod1=>p_nextObj
|
||||
fin
|
||||
if pMod2
|
||||
rawDisplayf3("^T%D%d %s", STATS_COL_2, pMod2=>w_modValue, pMod2=>s_name)
|
||||
pMod2 = pMod2=>p_nextObj
|
||||
fin
|
||||
loop
|
||||
fin
|
||||
|
||||
rawDisplayf2("\n\nPrice^T%D%d", STATS_COL_1, price)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def matchEquipped(pMatch, nSkip)
|
||||
word pPlayer, pItem, k1, k2
|
||||
pPlayer = global=>p_players
|
||||
while pPlayer
|
||||
pItem = pPlayer=>p_items
|
||||
while pItem
|
||||
printf2(" pl=$%x it=$%x\n", pPlayer, pItem)
|
||||
if (pItem->t_type == pMatch->t_type) and (pItem->t_type == TYPE_WEAPON or pItem->t_type == TYPE_ARMOR)
|
||||
if (pItem->b_flags & ITEM_FLAG_EQUIP) and (pItem=>s_itemKind == pMatch=>s_itemKind)
|
||||
if nSkip == 0; return pItem; fin
|
||||
nSkip = nSkip - 1
|
||||
fin
|
||||
fin
|
||||
pItem = pItem=>p_nextObj
|
||||
loop
|
||||
pPlayer = pPlayer=>p_nextObj
|
||||
loop
|
||||
return NULL
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def browseItem(num)
|
||||
word pItem, price
|
||||
word pItem, price, compSkip, pComp
|
||||
pItem = pageItems[num]
|
||||
price = pagePrices[num]
|
||||
compSkip = 0
|
||||
|
||||
clearWindow()
|
||||
rawDisplayStr("^T108Browse\n\nItem:^T040")
|
||||
displayItemName(pItem)
|
||||
rawDisplayf1("\nPrice:^T040%d", price)
|
||||
getUpperKey()
|
||||
while TRUE
|
||||
clearWindow()
|
||||
rawDisplayStr("^T108Browse\n")
|
||||
puts("match\n")
|
||||
pComp = matchEquipped(compSkip)
|
||||
if compSkip > 0 and !pComp
|
||||
compSkip = 0; pComp = matchEquipped(compSkip)
|
||||
fin
|
||||
puts("disp\n")
|
||||
displayItemStats(pItem, price, pComp)
|
||||
if getUpperKey() == $1B // Esc
|
||||
break
|
||||
fin
|
||||
compSkip++
|
||||
loop
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user