Skip to content

Commit

Permalink
initial implementation of cargo trading
Browse files Browse the repository at this point in the history
  • Loading branch information
daelsepara committed Oct 20, 2020
1 parent 3d91fd4 commit 621377a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 4 deletions.
73 changes: 70 additions & 3 deletions src/bloodsea.zil
Original file line number Diff line number Diff line change
Expand Up @@ -2923,7 +2923,7 @@
)>
<RETURN .COUNT>>

<ROUTINE PRINT-MENU (CHOICES ITEM-MENU SHOW-STATS "OPT" EXIT-KEY EXIT-TEXT PRICES (NO-QUANTITY F)"AUX" ITEMS)
<ROUTINE PRINT-MENU (CHOICES ITEM-MENU SHOW-STATS "OPT" EXIT-KEY EXIT-TEXT PRICES (NO-QUANTITY F) "AUX" ITEMS)
<COND (<NOT .CHOICES> <RETURN>)>
<SET ITEMS <GET .CHOICES 0>>
<DO (I 1 .ITEMS)
Expand Down Expand Up @@ -6720,6 +6720,74 @@
<LOSE-STUFF ,CARGO ,LOST-STUFF "cargo" <- .COUNT .MAX> ,RESET-CARGO>
)>>

<ROUTINE STORY-TRADE-CARGO (ITEM LIST "OPT" (CONTAINER NONE) (UNITS 1) "AUX" (COUNT 0) (ITEMS 0) (QUANTITY 0) (GOODS NONE) (KEY NONE) (CHOICE 0))
<COND (<OR <NOT .ITEM> <NOT .LIST>> <RETURN>)>
<COND (<NOT .CONTAINER> <SET .CONTAINER ,CARGO>)>
<SET COUNT <GET .LIST 0>>
<SET GOODS <LTABLE NONE NONE NONE>>
<DO (I 1 .COUNT)
<COND (<IN? <GET .LIST .I> .CONTAINER>
<INC .ITEMS>
<PUT .GOODS .ITEMS <GET .LIST .I>>
)>
>
<COND (<G? .ITEMS 0>
<PUT .GOODS 0 .ITEMS>
<DO (I 1 .UNITS)
<REPEAT ()
<CRLF>
<TELL "Get">
<COND (<G? .I 1>
<TELL " another unit of ">
)(ELSE
<TELL " the ">
)>
<PRINT-ITEM .ITEM T>
<TELL " in exchange for your: " CR>
<DO (J 1 .ITEMS)
<HLIGHT ,H-BOLD>
<TELL N .J>
<HLIGHT ,H-NORMAL>
<TELL " - " <GET .GOODS .J> CR>
>
<HLIGHT ,H-BOLD>
<TELL "0">
<HLIGHT ,H-NORMAL>
<TELL " - You do not wish to trade" CR>
<TELL "Select cargo to trade: ">
<REPEAT ()
<SET KEY <INPUT 1>>
<COND (<OR <EQUAL? .KEY 0> <AND <G=? .KEY !\1> <L=? .KEY <+ !\0 .ITEMS>>>>
<RETURN>
)>
>
<COND (<EQUAL? .KEY !\0>
<RETURN>
)(ELSE
<SET CHOICE <- .KEY !\0>>
<COND (<IN? <GET .GOODS .CHOICE> .CONTAINER>
<SET QUANTITY <GETP <GET .GOODS .CHOICE> ,P?QUANTITY>>
<COND (<G? .QUANTITY 1>
<DEC .QUANTITY>
<PUTP <GET .GOODS .CHOICE> ,P?QUANTITY .QUANTITY>
<STORY-GAIN-CARGO .ITEM 1>
)(ELSE
<REMOVE <GET .GOODS .CHOICE>>
<PUTP <GET .GOODS .CHOICE> ,P?QUANTITY 1>
<STORY-GAIN-CARGO .ITEM 1>
)>
<RETURN>
)(ELSE
<EMPHASIZE "Your ship is not carrying that cargo!">
)>
)>
>
<COND (<EQUAL? .KEY !\0> <RETURN>)>
>
)(ELSE
<EMPHASIZE "You do not have cargo they are interested in.">
)>>

<CONSTANT TEXT-DROWNED "You drowned!">
<CONSTANT TEXT-SWEPT-MIRACULOUSLY "You are swept miraculously to the shore">
<CONSTANT TEXT-SHIPWRECK "Helpless in the grip of the storm, the vessel cracks apart. The seawater rushes into the broken shell of the hull, dragging you down. The screams of your crewmen are drowned out by the howl of the storm.||They are lost forever. You can think of nothing not but saving yourself.">
Expand Down Expand Up @@ -15362,9 +15430,8 @@ back with reinforcements soon.\"||You agree.">
(CONTINUE STORY264)
(FLAGS LIGHTBIT)>

; "TO-DO: Implement Cargo Trading"
<ROUTINE STORY569-EVENTS ()
<RETURN>>
<STORY-TRADE-CARGO ,CARGO-SPICES <LTABLE CARGO-FURS CARGO-TIMBER CARGO-GRAINS> ,CARGO 2>>

<CONSTANT TEXT570 "You cannot make any headway. Your ship is trapped in the Sea of Reeds; each day your supplies of food and water get lower and lower.">

Expand Down
2 changes: 1 addition & 1 deletion src/validator
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
grep -n '(STORY' bloodsea.zil | grep -v '(STORY TEXT' | grep -v '(STORY NONE)' | grep -v 'STORY-JUMP (STORY)' | grep -v '(STORY "' | grep -v '(STORY JUMP ' | grep -v '(STORY SHACK ' | grep -v '(STORY INDEX ' | grep -v 'SET-DESTINATION (STORY DESTINATION' | grep -v 'PROCESS-HOUSE (STORY ' | grep -v 'STORAGE-MONEY (STORY ' | grep -v 'STORAGE-POSSESSIONS (STORY ' | grep -v 'VISIT-STORAGE (STORY ' | grep -v 'PROCESS-COLLEGE (STORY COLLEGE'
grep -n '(CHOICE' bloodsea.zil | grep -v '(CHOICES CHOICES' | grep -v '(CHOICES NONE)' | grep -v '(CHOICES "AUX"' | grep -v '<ROUTINE PRINT-MENU' | grep -v '(CHOICES SMOGMAW-'
grep -n '(CHOICE' bloodsea.zil | grep -v '(CHOICES CHOICES' | grep -v '(CHOICES NONE)' | grep -v '(CHOICES "AUX"' | grep -v '<ROUTINE PRINT-MENU' | grep -v '(CHOICES SMOGMAW-' | grep -v '(CHOICE 0)'
grep -n '(CONTINUE' bloodsea.zil | grep -v '(CONTINUE STORY' | grep -v '(CONTINUE NONE)' | grep -v '(CONTINUE SMOGMAW-' | grep -v '(CONTINUE COPPER-' | grep -v '(CONTINUE VERVAYENS-' | grep -v '(CONTINUE SHAMANS-'
grep -n '(DESTINATION' bloodsea.zil | grep -v '(DESTINATIONS <LTABLE ' | grep -v '(DESTINATIONS <PLTABLE ' | grep -v '(DESTINATIONS NONE)' | grep -v 'RESULT (DESTINATION NONE)' | grep -v '(DESTINATIONS SMOGMAW-' | grep -v '(DESTINATIONS STORY'
grep -n '(REQUIREMENTS' bloodsea.zil | grep -v '(REQUIREMENTS NONE)' | grep -v '(REQUIREMENTS <LTABLE ' | grep -v '(REQUIREMENTS <PLTABLE ' | grep -v '(REQUIREMENTS STORY' | grep -v '(REQUIREMENTS SMOGMAW-'
Expand Down

0 comments on commit 621377a

Please sign in to comment.