(FILECREATED "23-Dec-85 13:57:53" {PHYLUM}<LOOPS>SOURCES>TRUCKIN>TRUCKINR.;3 64808 changes to: (CLASSES Producer SystemTruck) previous date: "26-Mar-85 19:44:06" {PHYLUM}<LOOPS>SOURCES>TRUCKIN>TRUCKINR.;1) (* Copyright (c) 1985 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT TRUCKINRCOMS) (RPAQQ TRUCKINRCOMS ((* Copyright (c) 1983 Xerox Corp) (* TRUCKIN Domain for Expert Systems. Created by Loops Design Team - Danny Bobrow, Sanjay Mittal, and Mark Stefik) (* Objects and associated methods for Commodity and RoadStop classes) (CLASSES * TRUCKINRCLASSES) (FNS CommodityTransportability.CheckFragility CommodityTransportability.UpdateStatus RoadStop.BwPlace RoadStop.ColorPlace RoadStop.DisplayIcon) (METHODS Commodity.CanTransfer Commodity.CheckFragility Commodity.Display Commodity.TransferOwner Commodity.UpdateStatus Consumer.Buy Consumer.BuyFuel Consumer.CanBuy Consumer.DisplayData Consumer.DisplayIcon Consumer.Show FragileCommodity.CheckFragility FragileCommodity.PartialTransfer OtherRoadStop.DisplayIcon OtherRoadStop.Initialize OtherRoadStop.ReInitialize OtherRoadStop.Show PerishableCommodity.PartialTransfer PerishableCommodity.UpdateStatus Producer.DisplayData Producer.DisplayIcon Producer.Sell Producer.SellFuel Producer.Show RoadStop.AnyVictim RoadStop.BWDisplay RoadStop.Bandit? RoadStop.BanditP RoadStop.BanditReady RoadStop.ColorDisplay RoadStop.Crash RoadStop.Display RoadStop.DisplayData RoadStop.Flash RoadStop.GoingPast RoadStop.Initialize RoadStop.Park RoadStop.Parked? RoadStop.Place RoadStop.ReInitialize RoadStop.RoomToPark? RoadStop.TimeSpent RoadStop.TurnsStayed RoadStop.Unpark RoadStop.Visit SystemTruck.Buy SystemTruck.CanBuy SystemTruck.Sell Truck.BuyFuel Truck.CanBuyFuel Truck.FillTank Truck.Initialize Truck.SellFuel Truck.VisitUnionHall))) (* Copyright (c) 1983 Xerox Corp) (* TRUCKIN Domain for Expert Systems. Created by Loops Design Team - Danny Bobrow, Sanjay Mittal, and Mark Stefik) (* Objects and associated methods for Commodity and RoadStop classes) (RPAQQ TRUCKINRCLASSES (Commodity CommodityTransportability Consumer FragileCommodity OtherRoadStop PerishableCommodity Producer RoadStop SystemTruck Truck)) (DEFCLASSES Commodity CommodityTransportability Consumer FragileCommodity OtherRoadStop PerishableCommodity Producer RoadStop SystemTruck Truck) [DEFCLASS Commodity (MetaClass CommodityClassMeta Edited: (* dgb: "23-SEP-83 09:33")) (Supers GameObject) (ClassVariables (VolPerQty 1 doc (* volume occupied by unit quantity)) (WtPerQty 1 doc (* weight per unit qty)) (AvgPrice 1 doc (* avg unit price for buying or selling by truckers) ) (Icon defaultIcon doc (* name of a variable which is bound to a Bitmap) ) (CopyCV (VolPerQty WtPerQty AvgPrice Icon))) (InstanceVariables (qty 0 doc (* actual qty on hand for truck)) (pr .9 doc (* this is the actual price RATIO paid by a trucker) ) (owner *SYSTEM* doc (* truck object which owns this commodity) ) (status T doc (* whether the commodity is alright or not. NIL would mean the commodity has been destroyed) ))] [DEFCLASS CommodityTransportability (MetaClass GameClass Edited: (* sm: "26-JAN-83 17:34")) (Supers GameObject) (ClassVariables (CopyCV NIL))] [DEFCLASS Consumer (MetaClass GameClass doc (* * RoadStops that buy goods from Truckers.) Edited: (* mjs: "20-FEB-83 12:51") ) (Supers RoadStop) (ClassVariables (Pr 1.3) (Commodity #$Commodity doc (* The commodity to be purchased from truckers, that is, a generic Loops class descriptive of the goods.) ) (CopyCV (Pr Qty Commodity)) (Qty 500) (Shade ConsumerShade)) (InstanceVariables (qty #(#((GenConsumerQty self) FirstFetch ReplaceMe) NIL UpdateConsumerDisplay) doc (* quantity of goods to be purchased. Decreases as goods are purchased.)) (pr #(#((GenConsumerPr self) FirstFetch ReplaceMe) NIL UpdateConsumerDisplay) doc (* price ratio. This is multiplied times the AvgBuyingPrice for Commodities to determine the price paid to truckers.)))] [DEFCLASS FragileCommodity (MetaClass CommodityClassMeta Edited: (* sm: "28-JAN-83 21:31")) (Supers CommodityTransportability) (ClassVariables (FragilityLevel 20 doc (* breakability on a scale of 1 to 20)) (CopyCV (FragilityLevel))) (InstanceVariables (fragility #((RAND 1 (@@ FragilityLevel)) FirstFetch ReplaceMe)))] [DEFCLASS OtherRoadStop (MetaClass GameClass Edited: (* sm: "10-FEB-83 16:37")) (Supers RoadStop) (ClassVariables (Icon ?) (Shade OtherRoadStopShade))] [DEFCLASS PerishableCommodity (MetaClass CommodityClassMeta Edited: (* mjs: "25-JAN-83 13:23")) (Supers CommodityTransportability) (ClassVariables (MinLifetime 2 doc (* min number of turns before commodity perishes) ) (MaxLifetime 20 doc (* max number of turns by when commodity perishes) ) (CopyCV (MinLifetime MaxLifetime))) (InstanceVariables (lifetime #(NIL SmashRandomPerishable NIL)))] [DEFCLASS Producer (MetaClass GameClass doc (* * RoadStops that sell goods to Truckers.) Edited: (* mjs: "20-FEB-83 12:51") ) (Supers RoadStop) (ClassVariables (Commodity #$Commodity doc (* class of commodity sold by this producer) ) (Pr .9 doc (* price ratio at which this producer typically sells. used to generate ACTUAL pr)) (Qty 50 doc (* quantity typically sold by this producer. used to generate ACTUAL qty)) (CopyCV (Pr Qty Commodity)) (Shade ProducerShade)) (InstanceVariables (qty #(#((GenConsumerQty self) FirstFetch ReplaceMe) NIL UpdateConsumerDisplay) doc (* actual qty available)) (pr #(#((GenConsumerPr self) FirstFetch ReplaceMe) NIL UpdateConsumerDisplay) doc (* actual price ratio at which sold)))] [DEFCLASS RoadStop (MetaClass AbstractClass doc (* * A RoadStop on the game board for TRUCKIN. Subclasses of this class are saved on the global list RoadStops. Instances of these subclasses can be included on the game board by the gameMaster when a simulation is set up.) Edited: (* sm: "14-JUN-83 15:01") ) (Supers GameObject) (ClassVariables (RoadSign "RoadSign" doc (* String name to appear in the display.) ) (Width 75 doc (* width of RoadStop in pixels.)) (Height 75 doc (* height of RoadStop in pixels.)) (CopyCV (RoadSign))) (InstanceVariables (milePost 0 doc (* index of this RoadStop on the road. Assigned by Place message.)) (prev NIL doc (* previous RoadStop on the board. NIL if this is the beginning of the road.) ) (next NIL doc (* next RoadStop on the board. NIL if this is the end of the road.)) (parkingPlace1 NIL howLong 0 timeParked 0 timeUsed 0 doc (* First parking place at RoadStop.) pdoc (* timeParked - time when first parked at Alice. timeUsed - time used computing at Alice) ) (parkingPlace2 NIL howLong 0 timeParked 0 timeUsed 0 doc (* Second parking place at this RoadStop.) ) (x 0 doc (* xOrigin on display in pixels. Assigned by Place message.)) (y 0 doc (* yOrigin on display in pixels. Assigned by Place message.)) (roadOrientation NIL doc (* Left or Right. Right means that next RoadStop is down the road to the right in the display.) ))] [DEFCLASS SystemTruck (MetaClass GameAbstractClass doc (* System trucks -- includes ones that cannot be used by User-defined Players.) Edited: (* sm: " 7-JUN-83 14:16") ) (Supers GameObject) (ClassVariables (InitCash 10000) (Gpm 1 doc (* units of fuel used per moved location) ) (Icon ? doc (* name of LISP variable bound to Bitmap) ) (MaxDamage 10 doc (* maximum damage)) (MaxDist 15 doc (* max moves allowed in each turn)) (MaxFuel 30 doc (* max units of fuel truck can carry)) (MaxVolume 200 doc (* max volume)) (MaxWeight 200 doc (* max weight in commodity units)) (CopyCV (InitCash MaxFuel MaxVolume MaxWeight MaxDamage MaxDist Gpm Icon))) (InstanceVariables (driver NIL doc (* player driving this truck.)) (location NIL reason NIL doc (* current location on the road. A RoadStop.)) (cargo NIL doc (* cargo on the truck as a list of Commodity instances)) (cashBox #((@@ InitCash) FirstFetch ReplaceMe) DefaultGauge LCD GaugeLimit (0 1000000) doc (* money carried on the truck.) ) (damage 0 DefaultGauge NIL doc (* current damage to truck)) (fuel #((@@ MaxFuel) FirstFetch ReplaceMe) DefaultGauge Dial GaugeLimit #((LIST 0 (@@ MaxFuel)) FirstFetch ReplaceMe) doc (* fuel left in truck) ) (volume 0 DefaultGauge NIL GaugeLimit #((LIST 0 (@@ MaxVolume)) FirstFetch ReplaceMe) doc (* volume used) ) (weight 0 DefaultGauge NIL GaugeLimit #((LIST 0 (@@ MaxWeight)) FirstFetch ReplaceMe) doc (* weight on truck) ))] [DEFCLASS Truck (MetaClass GameAbstractClass Edited: (* mjs: "16-MAR-83 14:43")) (Supers SystemTruck)] (DEFINEQ (CommodityTransportability.CheckFragility [LAMBDA (self rs speed) (* sm: "26-JAN-83 17:18") (* dummy method for checking fragility) T]) (CommodityTransportability.UpdateStatus [LAMBDA (self newStop oldStop) (* sm: "26-JAN-83 17:18") (* dummy for Updateing status of commodities as they move) T]) (RoadStop.BwPlace [LAMBDA (self x y milePost roadOrientation) (* sm: "27-JUN-83 18:32") (* Save RoadStop placement information) (COND (x (* Here if x y & milePost are given as args.) (←@ x x) (←@ y y) (←@ milePost milePost) (←@ roadOrientation roadOrientation)) (T (* Here if OLD x y & milePost are used.) (SETQ x (@ x)) (SETQ y (@ y)) (SETQ milePost (@ milePost)) (SETQ roadOrientation (@ roadOrientation]) (RoadStop.ColorPlace [LAMBDA (self x y milePost roadOrientation) (* sm: "27-JUN-83 18:35") (* Save the RoadStop position information in instance variables.) (COND (x (* Here if x y & milePost are given as args.) (←@ x x) (←@ y y) (←@ milePost milePost) (←@ roadOrientation roadOrientation)) (T (* Here if OLD x y & milePost are used.) (SETQ x (@ x)) (SETQ y (@ y)) (SETQ milePost (@ milePost)) (SETQ roadOrientation (@ roadOrientation]) (RoadStop.DisplayIcon [LAMBDA (self) (* mjs: "12-JAN-83 10:29") (* * Display the Icon for the Commodity or Hazard in the RoadStop.) (PROG (icon (commodityName (@ commodity)) (commodity (GetClassRec (@ commodity))) (yOffset 5) xIcon yIcon) (* * Compute y coordinate for icon.) (SETQ yIcon (IPLUS (@ y) yPr (FONTPROP dataFont (QUOTE HEIGHT)) yOffset)) (* * Handle Producers, Consumers, and Hazards differently.) (COND ((← self InstOf ($ Consumer)) (* If a Consumer, just print the name of the commodity.) (SETQ xIcon (IPLUS (@ x) (IQUOTIENT (IDIFFERENCE (@@ Width) (STRINGWIDTH commodityName dataFont)) 2))) (DSPXPOSITION xIcon gameWindow) (DSPYPOSITION yIcon gameWindow) (DSPFONT dataFont gameWindow) (PRIN2 commodityName gameWindow)) (T (* Otherwise, if a Producer or a Hazard, use an icon if available.) (SETQ xIcon (IPLUS (@ x) (IQUOTIENT (IDIFFERENCE (@@ Width) iconSide) 2]) ) [METH Commodity CanTransfer (newOwner pr qty prevOwner) (* Checks if ownership can be transferred)] [METH Commodity CheckFragility (rs speed) (* dummy method for checking fragility)] [METH Commodity Display NIL (* Displays the small icon from Truckin in its own window)] [METH Commodity TransferOwner (newOwner priceRatio qty) (* transfers the commodity from one owner to another)] [METH Commodity UpdateStatus (newStop oldStop) (* dummy for Updating status of commodities as they move)] [METH Consumer Buy (commodity prevOwner) (* perform BUY for a consumer)] [METH Consumer BuyFuel (commodity prevOwner) NIL] [METH Consumer CanBuy (commodity pr qty seller) (* checks if consumer will buy this commodity)] [METH Consumer DisplayData NIL (* * Display the Qty and PR for the Consumer at a RoadStop.)] [METH Consumer DisplayIcon NIL (* * Display the Icon for a RoadStop that is a Consumer..)] [METH Consumer Show NIL NIL] [METH FragileCommodity CheckFragility (hazard dist) (* checks if fragile commodities have broken for currentPlayer's truck)] [METH FragileCommodity PartialTransfer (copyFrom) (* copies ivs when commodities have to be split up for partial buys)] [METH OtherRoadStop DisplayIcon NIL (* * Display the Icon for an OtherRoadStop.)] [METH OtherRoadStop Initialize NIL (* does nothing)] [METH OtherRoadStop ReInitialize NIL (* Same as Initialize)] [METH OtherRoadStop Show NIL (* prints a message)] [METH PerishableCommodity PartialTransfer (copyFrom) (* copies IVs specific to this class to transferred commodity)] [METH PerishableCommodity UpdateStatus (newStop oldStop) (* updates the status of the Commodity after each move)] [METH Producer DisplayData NIL (* Display the Qty and PR for the Producer at a RoadStop.)] [METH Producer DisplayIcon NIL (* Display the Icon for a RoadStop that is a Producer.)] [METH Producer Sell (commodity pr qty) (* perform SELL for consumer)] [METH Producer SellFuel (commodity pr qty) NIL] [METH Producer Show NIL (* shows the producer roadstop data)] [METH RoadStop AnyVictim NIL (* checks and returns the name of any non-bandit player at this loc)] [METH RoadStop BWDisplay NIL (* Does a BW display of a roadStop)] [METH RoadStop Bandit? NIL (* checks if there is a bandit here)] [METH RoadStop BanditP NIL (* checks if there is a bandit here)] [METH RoadStop BanditReady NIL (* checks if Bandit is ready to catch passing trucks)] [METH RoadStop ColorDisplay NIL (* Does a color display of roadStop)] [METH RoadStop Crash (player) (* Crashes player at this RoadStop if already parked. Else parks player in crashed state.)] [METH RoadStop Display NIL (* Actually displays roadStop)] [METH RoadStop DisplayData NIL (* * Dummy routine for displaying no data in an OtherRoadStop.)] [METH RoadStop Flash (player) (* flashes currentPlayer)] [METH RoadStop GoingPast (player dist) (* Message sent when a player wats to go past this roadstop.)] [METH RoadStop Initialize NIL (* Initializes roadStop the very first time without triggering display)] [METH RoadStop Park (player tempFlg time) (* Park the current player at this RoadStop.)] [METH RoadStop Parked? (player) (* * Returns T if the currentPlayer is parked at this RoadStop, and NIL otherwise.)] [METH RoadStop Place (x y milePost roadOrientation) (* Save RoadStop placement information)] [METH RoadStop ReInitialize NIL (* Initializes roadStop if subsequently reused. Does trigger display)] [METH RoadStop RoomToPark? NIL (* * Returns T if there is room to park at this RoadStop and NIL otherwise.)] [METH RoadStop TimeSpent (player) (* returns the time spent by player at this stop, if parked here)] [METH RoadStop TurnsStayed (player) (* If player is parked here, returns how long he has been here)] [METH RoadStop Unpark (player) (* Removes the current player from his parking place at a RoadStop.)] [METH RoadStop Visit (player reason time) (* player is visiting this stop)] [METH SystemTruck Buy (commodity prevOwner) (* sm: " 8-FEB-83 14:20")] [METH SystemTruck CanBuy (commodity pr qty seller) (* sm: " 8-FEB-83 14:16")] [METH SystemTruck Sell (commodity pr qty) (* sm: " 9-FEB-83 15:51")] [METH Truck BuyFuel (fuelInst prevOwner) (* buys Fuel and puts in fuel tank)] [METH Truck CanBuyFuel (commodity pr qty seller) (* check if the truck can buy fuel)] [METH Truck FillTank (fuelInst) (* sm: "20-JAN-83 16:12")] [METH Truck Initialize NIL NIL] [METH Truck SellFuel (commodity pr qty) (* perform the SELL fuel transaction for truck)] [METH Truck VisitUnionHall NIL (* initialize truck data for going to UnionHall)] (DEFINEQ (Commodity.CanTransfer (Method ((Commodity CanTransfer) self newOwner pr qty prevOwner) (* sm: " 6-JUN-83 16:03") (* Checks if ownership can be transferred) (* Complete protocol. Not needed yet. (AND (COND ((@ owner) (* can current owner sell?) (← (@ owner) CanSell self (COND ((NULL pr) (@ pr)) (T pr)) (COND ((NULL qty) (@ qty)) (T qty)))) (T T)) (← newOwner CanBuy self (COND ((NULL pr) (@ pr)) (T pr)) (COND ((NULL qty) (@ qty)) (T qty)) prevOwner))) (← newOwner CanBuy self (COND ((NULL pr) (@ pr)) (T pr)) (COND ((NULL qty) (@ qty)) (T qty)) prevOwner))) (Commodity.CheckFragility (Method ((Commodity CheckFragility) self rs speed) (* sm: "26-JAN-83 17:18") (* dummy method for checking fragility) T)) (Commodity.Display [Method ((Commodity Display) self) (* dgb: "23-JUN-83 08:29") (* Displays the small icon from Truckin in its own window) (MOVEW (OPENW (CREATEWFROMIMAGE (BITMAPCOPY (EVALV (GetClassValue self (QUOTE Icon]) (Commodity.TransferOwner (Method ((Commodity TransferOwner) self newOwner priceRatio qty) (* sm: "13-JUN-83 08:15") (* transfers the commodity from one owner to another) (* If qty is not specified, all is transferred, else only qty is transferred by creating a new instance) (* If priceRatio is not specified, then uses one currently in self) (PROG (transfer (prevOwner (@ owner)) (tpr priceRatio) (tqty qty)) [COND ((NULL tpr) (SETQ tpr (@ pr] [COND ((NULL tqty) (SETQ tqty (@ qty] (* ask the previous owner to sell the specified qty) (← prevOwner Sell self tpr tqty) (COND ((OR (NULL qty) (EQUAL qty (@ qty))) (* transfer completely) (SETQ transfer self)) (T (* create a new instance to only transfer specified qty) (SETQ transfer (← (Class self) New (COND ((NULL priceRatio) (@ pr)) (T priceRatio)) qty (QUOTE *SPECIAL*))) (PutValue self (QUOTE qty) (DIFFERENCE (@ qty) qty)) (* PartialTransfer message copies those aspects of self which have to be copied over but may depend on the actual classification of self) (DoFringeMethods transfer (QUOTE PartialTransfer) self))) (* write the new owner's name) (PutValue transfer (QUOTE owner) newOwner) (* ask new owner to update accounts and stock for BUY) (← newOwner Buy transfer prevOwner) (RETURN transfer)))) (Commodity.UpdateStatus (Method ((Commodity UpdateStatus) self newStop oldStop) (* sm: "26-JAN-83 17:18") (* dummy for Updateing status of commodities as they move) T)) (Consumer.Buy (Method ((Consumer Buy) self commodity prevOwner) (* sm: " 8-FEB-83 14:13") (* perform BUY for a consumer) (PROG NIL (* update qty to be bought) [←@ qty (IMAX 0 (IDIFFERENCE (@ qty) (GetValue commodity (QUOTE qty] (RETURN self)))) (Consumer.BuyFuel (Method ((Consumer BuyFuel) self commodity prevOwner) (Consumer.Buy self commodity prevOwner))) (Consumer.CanBuy (Method ((Consumer CanBuy) self commodity pr qty seller) (* dgb: " 9-JUN-83 14:30") (* checks if consumer will buy this commodity) (* Returns self if can, else NIL) (PROG NIL (* check that commodity is not perished) (COND ((NULL (@ commodity status)) (SETQ FCTReason (QUOTE PerishedGoods)) (SETQ FCTPenalty .2) (RETURN NIL))) (* check if want to buy this commodity) (COND ((← commodity InstOf!(@@ Commodity))) (T (SETQ FCTReason (QUOTE InvalidCommodity)) (SETQ FCTPenalty .2) (RETURN NIL))) (* check qty) (COND ((GREATERP qty (@ qty)) (SETQ FCTReason (QUOTE TooMuchQty)) (SETQ FCTPenalty .1) (RETURN NIL))) (* check pr) (COND ((GREATERP pr (@ pr)) (SETQ FCTReason (QUOTE PriceHigh)) (SETQ FCTPenalty .1) (RETURN NIL))) (RETURN self)))) (Consumer.DisplayData (Method ((Consumer DisplayData) self) (* sm: " 5-JUL-83 18:50") (* * Display the Qty and PR for the Consumer at a RoadStop.) (PROG (x y str) (* * Erase old string.) (DSPCOLOR consumerIconColor gameWindow) (DSPBACKCOLOR roadStopColor gameWindow) (BITBLT blankDataIcon NIL NIL gameWindow (IPLUS (@ x) lineSize) (IPLUS (@ y) yData)) (* Compute New String.) [SETQ str (COND ((ZEROP (@ qty)) "ENOUGH!!") (T (CONCAT (@ qty) " @ " (STRINGNUM (@ pr) 4] (* * Compute Coordinates to center the string.) [SETQ x (IPLUS (@ x) (MAX 0 (IQUOTIENT (IDIFFERENCE (@@ Width) (STRINGWIDTH str dataFont)) 2] (SETQ y (IPLUS (@ y) yData 1)) (* * Print the string.) (DSPXPOSITION x gameWindow) (DSPYPOSITION y gameWindow) (DSPFONT dataFont gameWindow) (PRIN1 str gameWindow)))) (Consumer.DisplayIcon (Method ((Consumer DisplayIcon) self) (* agb: "12-FEB-83 20:15") (* * Display the Icon for a RoadStop that is a Consumer.) (PROG ((commodityName (ClassName (@@ Commodity))) (yOffset 5) xIcon yIcon) (* * Print the name of the commodity, rather than displaying an Icon.) (SETQ yIcon (IPLUS (@ y) yData (FONTPROP commodityFont (QUOTE HEIGHT)) yOffset)) (SETQ xIcon (IPLUS (@ x) (IQUOTIENT (IDIFFERENCE (@@ Width) (STRINGWIDTH commodityName commodityFont)) 2))) (DSPXPOSITION xIcon gameWindow) (DSPYPOSITION yIcon gameWindow) (DSPCOLOR consumerIconColor gameWindow) (DSPBACKCOLOR roadStopColor gameWindow) (DSPFONT commodityFont gameWindow) (PRIN2 commodityName gameWindow)))) (Consumer.Show (Method ((Consumer Show) self) (* sm: " 9-FEB-83 16:02") (* shows the consumer roadstop data) (PROG ((file PPDefault) (commodity (@@ Commodity))) (printout file T "*****************" T) (printout file "RoadStop: " (ClassName self) T) (printout file "Consumer of: " .FONT BOLDFONT (GetObjectName commodity) .FONT DEFAULTFONT T) (printout file "Data for: " (GetObjectName commodity) T) (for cv in (QUOTE (VolPerQty WtPerQty AvgPrice)) do (printout file cv 17 (GetClassValue commodity cv) T)) (RETURN T)))) (FragileCommodity.CheckFragility [Method ((FragileCommodity CheckFragility) self hazard dist) (* dgb: "14-JUL-83 18:37") (* checks if fragile commodities have broken for currentPlayer's truck) (PROG ((player (@(@ owner) driver)) (truck (@ owner))) (RETURN (COND [(LESSP (TIMES (@ hazard roughness) dist (@ fragility)) (TIMES 25 (@@ truck MaxDist] (T (* OOps - tough luck!!) [COND ((@ status) (← Communicator BreakCargo player (FindLocIndex self (@ truck cargo))) (* (←@ status NIL) (WriteGameStatus (CONCAT (@ currentPlayer driver) "'s Cargo of: ") (CONCAT (@ qty) " " (ClassName self) " units") " destroyed by RoughRoad")) ] NIL]) (FragileCommodity.PartialTransfer (Method ((FragileCommodity PartialTransfer) self copyFrom) (* sm: "26-JAN-83 17:20") (* copies ivs when commodities have to be split up for partial buys) (←@ fragility (@ copyFrom fragility)))) (OtherRoadStop.DisplayIcon (Method ((OtherRoadStop DisplayIcon) self) (* sm: " 5-JUL-83 18:52") (* * Display the Icon for an OtherRoadStop.) (PROG ((iconName (@@ Icon)) (yOffset 2) xIcon yIcon) (* * Display the Icon associated with the commodity.) (SETQ yIcon (IPLUS (@ y) yData (FONTPROP dataFont (QUOTE HEIGHT)) yOffset)) (SETQ xIcon (IPLUS (@ x) (IQUOTIENT (IDIFFERENCE (@@ Width) iconSide) 2))) (DSPCOLOR otherRoadStopIconColor gameWindow) (DSPBACKCOLOR roadStopColor gameWindow) (BITBLT (EVALV iconName) NIL NIL gameWindow xIcon yIcon)))) (OtherRoadStop.Initialize (Method ((OtherRoadStop Initialize) self) (* sm: "16-FEB-83 15:51") (* does nothing) (←@ parkingPlace1 NIL) (←@ parkingPlace2 NIL) self)) (OtherRoadStop.ReInitialize (Method ((OtherRoadStop ReInitialize) self) (* sm: "29-JUN-83 09:19") (* Same as Initialize) (← self Initialize))) (OtherRoadStop.Show (Method ((OtherRoadStop Show) self) (* edited: "31-JAN-83 21:54") (* prints a message) (printout PPDefault T "**********" T) (printout PPDefault (ClassName self) " is neither a producer nor a consumer" T))) (PerishableCommodity.PartialTransfer (Method ((PerishableCommodity PartialTransfer) self copyFrom) (* sm: "24-JAN-83 15:34") (* copies IVs specific to this class to transferred commodity) (←@ lifetime (@ copyFrom lifetime)))) (PerishableCommodity.UpdateStatus [Method ((PerishableCommodity UpdateStatus) self newStop oldStop) (* dgb: "14-JUL-83 18:37") (* updates the status of the Commodity after each move) (PROG ((player (@(@ owner) driver)) (truck (@ owner))) (←@ lifetime (SUB1 (@ lifetime))) [COND ((AND (@ status) (ZEROP (@ lifetime))) (← Communicator SpoilCargo player (FindLocIndex self (@ truck cargo))) (* (WriteGameStatus (CONCAT driver "'s Cargo of: ") (CONCAT (@ qty) " " (ClassName self) " units") " just perished") (←@ status NIL)) ] (RETURN (@ lifetime]) (Producer.DisplayData (Method ((Producer DisplayData) self) (* agb: "12-FEB-83 20:33") (* Display the Qty and PR for the Producer at a RoadStop.) (PROG (x y str) (* Erase old string.) (DSPCOLOR producerIconColor gameWindow) (DSPBACKCOLOR roadStopColor gameWindow) (BITBLT blankDataIcon NIL NIL gameWindow (IPLUS (@ x) lineSize) (IPLUS (@ y) yData)) (* Compute New String.) [SETQ str (COND ((ZEROP (@ qty)) "SOLD OUT") (T (CONCAT (FIX (@ qty)) " @ " (STRINGNUM (@ pr) 4] (* Compute Coordinates to center the string.) [SETQ x (IPLUS (@ x) (MAX 0 (IQUOTIENT (IDIFFERENCE (@@ Width) (STRINGWIDTH str dataFont)) 2] (SETQ y (IPLUS (@ y) yData 1)) (* Print the string.) (DSPXPOSITION x gameWindow) (DSPYPOSITION y gameWindow) (DSPFONT dataFont gameWindow) (PRIN1 str gameWindow)))) (Producer.DisplayIcon (Method ((Producer DisplayIcon) self) (* agb: "12-FEB-83 20:14") (* * Display the Icon for a RoadStop that is a Producer.) (PROG (iconName (commodity (@@ Commodity)) (yOffset 2) xIcon yIcon) [SETQ iconName (COND (commodity (@@ commodity Icon)) (T (QUOTE defaultIcon] (* * Display the Icon associated with the commodity.) (SETQ yIcon (IPLUS (@ y) yData (FONTPROP dataFont (QUOTE HEIGHT)) yOffset)) (SETQ xIcon (IPLUS (@ x) (IQUOTIENT (IDIFFERENCE (@@ Width) iconSide) 2))) (DSPCOLOR producerIconColor gameWindow) (DSPBACKCOLOR roadStopColor gameWindow) (BITBLT (EVALV iconName) NIL NIL gameWindow xIcon yIcon)))) (Producer.Sell (Method ((Producer Sell) self commodity pr qty) (* sm: " 8-FEB-83 14:11") (* perform SELL for consumer) (PROG NIL (* update stock) (←@ qty (IMAX 0 (IDIFFERENCE (@ qty) qty))) (RETURN self)))) (Producer.SellFuel (Method ((Producer SellFuel) self commodity pr qty) (Producer.Sell self commodity pr qty))) (Producer.Show (Method ((Producer Show) self) (* sm: " 9-FEB-83 16:02") (* shows the producer roadstop data) (PROG ((file PPDefault) (commodity (@@ Commodity))) (printout file T "*****************" T) (printout file "RoadStop: " (ClassName self) T) (printout file "Producer of: " .FONT BOLDFONT (GetObjectName commodity) .FONT DEFAULTFONT T) (printout file "Data for: " (GetObjectName commodity) T) (for cv in (QUOTE (VolPerQty WtPerQty AvgPrice)) do (printout file cv 17 (GetClassValue commodity cv) T)) (RETURN T)))) (RoadStop.AnyVictim [Method ((RoadStop AnyVictim) self) (* sm: "26-JAN-83 15:36") (* checks and returns the name of any non-bandit player at this loc) (PROG (loc) [SETQ loc (for x in (QUOTE (parkingPlace1 parkingPlace2)) thereis (AND (GetValue self x) (NOT (← (GetValue self x) InstOf!(QUOTE Bandit] (RETURN (COND (loc (GetValue self loc)) (T NIL]) (RoadStop.BWDisplay (Method ((RoadStop BWDisplay) self) (* sm: "27-JUN-83 18:32") (* Does a BW display of a roadStop) (PROG ((width (@@ Width)) (height (@@ Height)) (roadSign (@@ RoadSign)) (fontHeight (FONTPROP roadSignFont (QUOTE HEIGHT))) xOffset yOffset x y milePost roadOrientation) (SETQ x (@ x)) (SETQ y (@ y)) (SETQ milePost (@ milePost)) (SETQ roadOrientation (@ roadOrientation)) (* * Draw the surrounding outline.) (BITBLT NIL NIL NIL gameWindow x y width height (QUOTE TEXTURE) (QUOTE REPLACE) (EVALV (@@ Shade))) (BITBLT NIL NIL NIL gameWindow x y width lineSize (QUOTE TEXTURE) (QUOTE REPLACE) BLACKSHADE) (BITBLT NIL NIL NIL gameWindow x y lineSize height (QUOTE TEXTURE) (QUOTE REPLACE) BLACKSHADE) (BITBLT NIL NIL NIL gameWindow x (IPLUS y height (IMINUS lineSize)) width lineSize (QUOTE TEXTURE) (QUOTE REPLACE) BLACKSHADE) (BITBLT NIL NIL NIL gameWindow (IPLUS x width (IMINUS lineSize)) y lineSize height (QUOTE TEXTURE) (QUOTE REPLACE) BLACKSHADE) (* * Label the display with the RoadSign in an inverted bar.) (DSPFONT roadSignFont gameWindow) (SETQ xOffset (MAX lineSize (IQUOTIENT (IDIFFERENCE width (STRINGWIDTH roadSign roadSignFont)) 2))) (SETQ xOffset (IPLUS xOffset x)) [SETQ yOffset (IPLUS y height (IMINUS (FONTPROP roadSignFont (QUOTE HEIGHT] (BITBLT NIL NIL NIL gameWindow x yOffset width fontHeight (QUOTE TEXTURE) (QUOTE REPLACE) BLACKSHADE) (DSPTEXTURE BLACKSHADE gameWindow) (DSPOPERATION (QUOTE INVERT) gameWindow) (DSPXPOSITION xOffset gameWindow) (DSPYPOSITION (IPLUS yOffset 2) gameWindow) (PRIN1 roadSign gameWindow) (DSPTEXTURE WHITESHADE gameWindow) (DSPOPERATION (QUOTE REPLACE) gameWindow) (* * Display the Icon,qty, and pr.) (← self DisplayIcon) (← self DisplayData)))) (RoadStop.Bandit? [Method ((RoadStop Bandit?) self) (* sm: "27-JAN-83 18:24") (* checks if there is a bandit here) (* * RETURNS: Bandit instance if one is parked, else NIL) (PROG (banditLoc) (RETURN (COND ([SETQ banditLoc (for x in (QUOTE (parkingPlace1 parkingPlace2)) thereis (AND (GetObjectRec (GetValue self x)) (← (GetValue self x) InstOf!(QUOTE Bandit] (GetValue self banditLoc)) (T NIL]) (RoadStop.BanditP (Method ((RoadStop BanditP) self) (RoadStop.Bandit? self))) (RoadStop.BanditReady (Method ((RoadStop BanditReady) self) (* sm: "27-JAN-83 18:26") (* checks if Bandit is ready to catch passing trucks) (* * RETURNS: Bandit instance if ready, else NIL) (AND (← self RoomToPark?) (← self Bandit?)))) (RoadStop.ColorDisplay (Method ((RoadStop ColorDisplay) self) (* sm: "27-JUN-83 18:35") (* Does a color display of roadStop) (PROG ((width (@@ Width)) (height (@@ Height)) (roadSign (@@ RoadSign)) (fontHeight (FONTPROP roadSignFont (QUOTE HEIGHT))) xOffset yOffset x y milePost roadOrientation) (SETQ x (@ x)) (SETQ y (@ y)) (SETQ milePost (@ milePost)) (SETQ roadOrientation (@ roadOrientation)) (* * Draw the surrounding outline.) (BITBLT NIL NIL NIL gameWindow x y width height (QUOTE TEXTURE) (QUOTE REPLACE) roadStopColor) (BITBLT NIL NIL NIL gameWindow x y width lineSize (QUOTE TEXTURE) (QUOTE REPLACE) BLACKCOLOR) (BITBLT NIL NIL NIL gameWindow x y lineSize height (QUOTE TEXTURE) (QUOTE REPLACE) BLACKCOLOR) (BITBLT NIL NIL NIL gameWindow x (IPLUS y height (IMINUS lineSize)) width lineSize (QUOTE TEXTURE) (QUOTE REPLACE) BLACKCOLOR) (BITBLT NIL NIL NIL gameWindow (IPLUS x width (IMINUS lineSize)) y lineSize height (QUOTE TEXTURE) (QUOTE REPLACE) BLACKCOLOR) (* * Label the display with the RoadSign in an inverted bar.) (DSPFONT roadSignFont gameWindow) (SETQ xOffset (MAX lineSize (IQUOTIENT (IDIFFERENCE width (STRINGWIDTH roadSign roadSignFont)) 2))) (SETQ xOffset (IPLUS xOffset x)) [SETQ yOffset (IPLUS y height (IMINUS (FONTPROP roadSignFont (QUOTE HEIGHT] (BITBLT NIL NIL NIL gameWindow x yOffset width fontHeight (QUOTE TEXTURE) (QUOTE REPLACE) BLACKCOLOR) (DSPCOLOR roadStopNameColor gameWindow) (DSPBACKCOLOR BLACKCOLOR gameWindow) (DSPXPOSITION xOffset gameWindow) (DSPYPOSITION (IPLUS yOffset 2) gameWindow) (PRIN1 roadSign gameWindow) (* * Display the Icon,qty, and pr.) (← self DisplayIcon) (← self DisplayData)))) (RoadStop.Crash [Method ((RoadStop Crash) self player) (* dgb: "11-JUL-83 13:09") (* Crashes player at this RoadStop if already parked. Else parks player in crashed state.) (PROG (xPos yPos icon (xMargin (CONSTANT 2))) [SETQ icon (InvertIcon (COND ((EQ (@ roadOrientation) (QUOTE Right)) (@ player icon)) (T (@ player reverseIcon] (COND ((← self Parked? player) (← self Unpark player) (WAITMS 5))) (COND ((NULL (@ parkingPlace1)) (* * Here if there is room in the first space.) (←@ parkingPlace1 player) (SETQ xPos (IPLUS (@ x) xMargin)) (SETQ yPos (IPLUS (@ y) lineSize)) (AND gameWindow (BITBLT icon NIL NIL gameWindow xPos yPos))) ((NULL (@ parkingPlace2)) (* * Here if there is room in the 2nd space.) (←@ parkingPlace2 player) (SETQ xPos (IPLUS (@ x) (@@ Width) (IMINUS (@@ player Width)) (IMINUS xMargin))) (SETQ yPos (IPLUS (@ y) lineSize)) (AND gameWindow (BITBLT icon NIL NIL gameWindow xPos yPos))) (T (TruckinError "Attempt to Park when there is no room."]) (RoadStop.Display [Method ((RoadStop Display) self) (* sm: "29-JUN-83 09:24") (* Actually displays roadStop) (COND ((@@ GameBoard colorP) (← self ColorDisplay)) (T (← self BWDisplay]) (RoadStop.DisplayData (Method ((RoadStop DisplayData) self) (* sm: "28-JUN-83 09:49") (* * Dummy routine for displaying no data in an OtherRoadStop.) NIL)) (RoadStop.Flash (Method ((RoadStop Flash) self player) (* sm: "10-JUL-83 21:25") (* flashes currentPlayer) (* assumes currentPlayer is already parked there) (for i from 1 to 3 do (← self Crash player) (WAITMS 100) (← self Unpark player) (WAITMS 5) (← self Park player T) (WAITMS 100)))) (RoadStop.GoingPast (Method ((RoadStop GoingPast) self player dist) (* sm: " 7-JUN-83 11:59") (* Message sent when a player wats to go past this roadstop.) (* Returns: Reason if this RoadStop intercepts player. NIL otherwise) (* Any specialization must call this first before doing anything else) (* This one, i.e., in class RoadStop only checks for Bandits) (COND ((AND (← self BanditReady) (BanditGotYou? player self dist)) (QUOTE Bandit)) (T NIL)))) (RoadStop.Initialize (Method ((RoadStop Initialize) self) (* sm: "29-JUN-83 09:15") (* Initializes roadStop the very first time without triggering display) (←@ parkingPlace1 NIL) (←@ parkingPlace2 NIL) (GetValue self (QUOTE qty)) (GetValue self (QUOTE pr)) self)) (RoadStop.Park [Method ((RoadStop Park) self player tempFlg time) (* sm: "13-JUL-83 09:32") (* Park the current player at this RoadStop.) (* tempFlg if T means howLong and timeUsed props are not changed) (PROG (xPos yPos icon (xMargin (CONSTANT 2))) [SETQ icon (COND ((EQ (QUOTE Right) (@ roadOrientation)) (@ player icon)) (T (@ player reverseIcon] (COND ((NULL (@ parkingPlace1)) (* * Here if there is room in the first space.) (←@ parkingPlace1 player) [COND ((NOT tempFlg) (PutValue self (QUOTE parkingPlace1) 0 (QUOTE howLong)) (PutValue self (QUOTE parkingPlace1) 0 (QUOTE timeUsed)) (AND time (PutValue self (QUOTE parkingPlace1) time (QUOTE timeParked] (SETQ xPos (IPLUS (@ x) xMargin)) (SETQ yPos (IPLUS (@ y) lineSize)) (AND gameWindow (BITBLT icon NIL NIL gameWindow xPos yPos))) ((NULL (@ parkingPlace2)) (* * Here if there is room in the 2nd space.) (←@ parkingPlace2 player) [COND ((NOT tempFlg) (PutValue self (QUOTE parkingPlace2) 0 (QUOTE howLong)) (PutValue self (QUOTE parkingPlace2) 0 (QUOTE timeUsed)) (AND time (PutValue self (QUOTE parkingPlace2) time (QUOTE timeParked] (SETQ xPos (IPLUS (@ x) (@@ Width) (IMINUS (@@ player Width)) (IMINUS xMargin))) (SETQ yPos (IPLUS (@ y) lineSize)) (AND gameWindow (BITBLT icon NIL NIL gameWindow xPos yPos))) (T (TruckinError "Attempt to Park when there is no room."]) (RoadStop.Parked? [Method ((RoadStop Parked?) self player) (* sm: " 5-JUL-83 18:53") (* * Returns T if the currentPlayer is parked at this RoadStop, and NIL otherwise.) (OR (EQ player (@ parkingPlace1)) (EQ player (@ parkingPlace2]) (RoadStop.Place [Method ((RoadStop Place) self x y milePost roadOrientation) (* sm: "28-JUN-83 09:07") (* Save RoadStop placement information) (COND (x (* Here if x y & milePost are given as args.) (←@ x x) (←@ y y) (←@ milePost milePost) (←@ roadOrientation roadOrientation]) (RoadStop.ReInitialize [Method ((RoadStop ReInitialize) self) (* sm: "29-JUN-83 09:18") (* Initializes roadStop if subsequently reused. Does trigger display) (←@ parkingPlace1 NIL) (←@ parkingPlace2 NIL) (PutValue self (QUOTE qty) (GetInitialValue self (QUOTE qty))) (PutValue self (QUOTE pr) (GetInitialValue self (QUOTE pr]) (RoadStop.RoomToPark? [Method ((RoadStop RoomToPark?) self) (* mjs: "18-JAN-83 14:28") (* * Returns T if there is room to park at this RoadStop and NIL otherwise.) (OR (NULL (@ parkingPlace1)) (NULL (@ parkingPlace2]) (RoadStop.TimeSpent (Method ((RoadStop TimeSpent) self player) (* sm: " 7-JUL-83 10:32") (* returns the time spent by player at this stop, if parked here) (COND ((EQ player (@ parkingPlace1)) (IDIFFERENCE (IDATE) (@ self parkingPlace1 timeParked))) ((EQ player (@ parkingPlace2)) (IDIFFERENCE (IDATE) (@ self parkingPlace2 timeParked))) (T 0)))) (RoadStop.TurnsStayed (Method ((RoadStop TurnsStayed) self player) (* sm: "19-MAY-83 15:15") (* If player is parked here, returns how long he has been here) (COND ((EQ player (@ parkingPlace1)) (@ self parkingPlace1 howLong)) ((EQ player (@ parkingPlace2)) (@ self parkingPlace2 howLong)) (T 0)))) (RoadStop.Unpark [Method ((RoadStop Unpark) self player) (* dgb: "11-JUL-83 13:08") (* Removes the current player from his parking place at a RoadStop.) (PROG (xPos yPos (gb (@ Simulator gameBoard)) (xMargin (CONSTANT 2))) (COND [(EQ player (@ parkingPlace1)) (* * Here if player is in the first space.) (←@ parkingPlace1 NIL) (SETQ xPos (IPLUS (@ x) xMargin)) (SETQ yPos (IPLUS (@ y) lineSize)) (AND gameWindow (BITBLT NIL NIL NIL gameWindow xPos yPos (@@ player Width) (@@ player Height) (QUOTE TEXTURE) (QUOTE REPLACE) (COND ((@@ gb colorP) roadStopColor) (T (EVALV (@@ Shade] [(EQ player (@ parkingPlace2)) (* * Here if player is in the 2nd space.) (←@ parkingPlace2 NIL) (SETQ xPos (IPLUS (@ x) (@@ Width) (IMINUS (@@ player Width)) (IMINUS xMargin))) (SETQ yPos (IPLUS (@ y) lineSize)) (AND gameWindow (BITBLT NIL NIL NIL gameWindow xPos yPos (@@ player Width) (@@ player Height) (QUOTE TEXTURE) (QUOTE REPLACE) (COND ((@@ gb colorP) roadStopColor) (T (EVALV (@@ Shade] (T (TruckinError (CONCAT "Cannot Unpark " player " Not parked here"]) (RoadStop.Visit [Method ((RoadStop Visit) self player reason time) (* sm: "13-JUL-83 09:37") (* player is visiting this stop) (* IMPORTANT!! Any specialization of this must first do a ←Super) (* reason - if NIL, then requested by player, else reason for forced move) (PROG ((truck (@ player truck)) victim vtruck loss bandit) (← self Park player NIL time) (PutValue truck (QUOTE location) reason (QUOTE reason)) (←@ truck location self) [COND ((EQ reason (QUOTE LowFuel)) (* Moved here because of LowFuel) (WriteGameStatus (@ player driver) (CONCAT " Towed to " (@@ RoadSign)) (CONCAT " - " reason] (COND ((← player InstOf!(QUOTE Bandit)) (* visitor is Bandit. Check if anyone to rob) [COND ((SETQ victim (← self AnyVictim)) (← self Flash victim) (WriteGameStatus "BANDIDOS robbed you!! " (@ victim driver)) (SETQ vtruck (@ victim truck)) (SETQ loss (FIX (TIMES (@ vtruck cashBox) .2))) (ChangeValue vtruck (QUOTE cashBox) (IDIFFERENCE (@ vtruck cashBox) loss)) (WriteGameStatus "Cash lost: $" loss) (for x in (@ vtruck cargo) when (← x InstOf!(QUOTE LuxuryGoods)) do (COND ((← x TransferOwner player (@ player pr)) (WriteGameStatus "Bandits stole: " (CONCAT (@ x qty) " " (ClassName x)) " units"] (RETURN player)) (T (* visitor is regular player. see if bandits already here to rob him) [COND ((SETQ bandit (← self Bandit?)) (← self Flash player) [COND [(EQ reason (QUOTE Bandit)) (WriteGameStatus "BANDITS stopped you!! " (@ player driver) (CONCAT " at " (@@ RoadSign] (T (WriteGameStatus "BANDITS robbed you!! " (@ player driver] (SETQ loss (FIX (TIMES (@ truck cashBox) .2))) (ChangeValue truck (QUOTE cashBox) (IDIFFERENCE (@ truck cashBox) loss)) (WriteGameStatus "Cash lost: $" loss) (for x in (@ truck cargo) when (← x InstOf!(QUOTE LuxuryGoods)) do (COND ((← x TransferOwner bandit (@ bandit pr)) (WriteGameStatus "Bandits stole: " (CONCAT (@ x qty) " " (ClassName x)) " units"] (* if visiting involuntarily, crash) (COND ([AND reason (NOT (FMEMB reason (QUOTE (InitialPlacing] (← self Crash player))) (RETURN player]) (SystemTruck.Buy (Method ((SystemTruck Buy) self commodity prevOwner) (* sm: "19-MAY-83 15:25") (* sm: " 8-FEB-83 14:20") (* perform the BUY transaction for a trucker) (PROG (qty pr) (SETQ qty (GetValue commodity (QUOTE qty))) (SETQ pr (GetValue commodity (QUOTE pr))) (* update cashBox) [ChangeValue self (QUOTE cashBox) (FIX (DIFFERENCE (@ cashBox) (TIMES qty pr (GetClassValue commodity (QUOTE AvgPrice] (* update volume on truck) [←@ volume (PLUS (@ volume) (TIMES qty (@@ commodity VolPerQty] (* update weight) [←@ weight (PLUS (@ weight) (TIMES qty (@@ commodity WtPerQty] (* add this to cargo) (←@ cargo (CONS commodity (@ cargo))) (RETURN self)))) (SystemTruck.CanBuy (Method ((SystemTruck CanBuy) self commodity pr qty seller) (* sm: " 6-JUL-83 13:42") (* sm: " 8-FEB-83 14:16") (* check if the truck can buy the commodity) (* Returns self if can, else NIL) (PROG NIL (* check cashBox) (COND ((LESSP [DIFFERENCE (@ cashBox) (TIMES qty pr (GetClassValue commodity (QUOTE AvgPrice] 0) (SETQ FCTPenalty -1) (SETQ FCTReason (QUOTE InsufficientCash)) (RETURN NIL))) (* check volume on truck) (COND ((GREATERP (PLUS (@ volume) (TIMES qty (@@ commodity VolPerQty))) (@@ MaxVolume)) (SETQ FCTPenalty .05) (SETQ FCTReason (QUOTE InsufficientVolume)) (RETURN NIL))) (* check weight) (COND ((GREATERP (PLUS (@ weight) (TIMES qty (@@ commodity WtPerQty))) (@@ MaxWeight)) (SETQ FCTPenalty .05) (SETQ FCTReason (QUOTE InsufficientWeight)) (RETURN NIL))) (RETURN self)))) (SystemTruck.Sell (Method ((SystemTruck Sell) self commodity pr qty) (* sm: "19-MAY-83 15:26") (* sm: " 9-FEB-83 15:51") (* perform the SELL transaction for truck) (PROG NIL [COND ((NULL qty) (SETQ qty (GetValue commodity (QUOTE qty] [COND ((NULL pr) (SETQ pr (GetValue commodity (QUOTE pr] (* update cashBox) [ChangeValue self (QUOTE cashBox) (FIX (PLUS (@ cashBox) (TIMES qty pr (GetClassValue commodity (QUOTE AvgPrice] (* update volume) [←@ volume (DIFFERENCE (@ volume) (TIMES qty (@@ commodity VolPerQty] (* update weight) [←@ weight (DIFFERENCE (@ weight) (TIMES qty (@@ commodity WtPerQty] (* update cargo) [COND ((EQUAL qty (GetValue commodity (QUOTE qty))) (←@ cargo (REMOVE commodity (@ cargo] (RETURN self)))) (Truck.BuyFuel (Method ((Truck BuyFuel) self fuelInst prevOwner) (* sm: "19-MAY-83 15:24") (* buys Fuel and puts in fuel tank) (PROG NIL (←@ fuel (PLUS (@ fuel) (@ fuelInst qty))) [ChangeValue self (QUOTE cashBox) (FIX (DIFFERENCE (@ cashBox) (TIMES (@ fuelInst qty) (@ fuelInst pr) (@@ fuelInst AvgPrice] (RETURN self)))) (Truck.CanBuyFuel (Method ((Truck CanBuyFuel) self commodity pr qty seller) (* sm: " 6-JUN-83 18:11") (* check if the truck can buy fuel) (* Returns self if can, else NIL) (PROG NIL (* check cashBox) (COND ((LESSP [DIFFERENCE (@ cashBox) (TIMES qty pr (GetClassValue commodity (QUOTE AvgPrice] 0) (SETQ FCTPenalty -1) (SETQ FCTReason (QUOTE NoCash)) (RETURN NIL))) (* check fuel tank capacity) (COND ((GREATERP qty (DIFFERENCE (@@ MaxFuel) (@ fuel))) (SETQ FCTPenalty .01) (SETQ FCTReason (QUOTE NoCapacity)) (RETURN NIL))) (RETURN self)))) (Truck.FillTank (Method ((Truck FillTank) self fuelInst) (* sm: "20-JAN-83 16:16") (* sm: "20-JAN-83 16:12") (* sm: "20-JAN-83 15:27") (* transfers fuel from cargo to fuel tank) (PROG (availVol transVol) (SETQ availVol (DIFFERENCE (@@ MaxFuel) (@ fuel))) (COND ((GREATERP (@ fuelInst qty) availVol) (SETQ transVol (DIFFERENCE (@ fuelInst qty) availVol))) (T transVol (@ fuelInst qty))) (←@ fuel (PLUS (@ fuel) transVol)) [←@ volume (PLUS (@ volume) (TIMES transVol (@@ fuelInst VolPerQty] (←@ weight (PLUS (@ weight) transVol)) [COND [(EQUAL transVol (@ fuelInst qty)) (←@ cargo (REMOVE fuelInst (@ cargo] (T (←@ fuelInst qty (DIFFERENCE (@ fuelInst qty) transVol] (RETURN self)))) (Truck.Initialize (Method ((Truck Initialize) self) (* sm: "10-FEB-83 10:33") (* initialize truck to initial state) (←@ cargo NIL) (ChangeValue self (QUOTE cashBox) (@@ InitCash)) (←@ fuel (@@ MaxFuel)) (←@ volume 0) (←@ weight 0) (←@ damage 0))) (Truck.SellFuel (Method ((Truck SellFuel) self commodity pr qty) (* edited: " 2-AUG-83 14:07") (* perform the SELL fuel transaction for truck) (PROG NIL (* (COND ((NULL qty) (SETQ qty (GetValue commodity (QUOTE qty))))) (COND ((NULL pr) (SETQ pr (GetValue commodity (QUOTE pr))))) (* update cashBox) (←@ cashBox (PLUS (@ cashBox) (TIMES qty pr (GetClassValue commodity (QUOTE AvgBuyingPrice))))) (* update volume) (←@ volume (PLUS (@ volume) (TIMES qty (GetClassValue commodity (QUOTE VolPerQty))))) (* update weight) (←@ weight (PLUS (@ weight) qty)) (* update cargo) (COND ((EQUAL qty (GetValue commodity (QUOTE qty))) (←@ cargo (REMOVE self (@ cargo)))))) (printout TTY "Truckers cannot sell fuel!" T) (RETURN NIL)))) (Truck.VisitUnionHall (Method ((Truck VisitUnionHall) self) (* sm: "10-FEB-83 10:32") (* initialize truck data for going to UnionHall) (← self Initialize) (WriteGameStatus "Union Hall just gave " (@(@ driver) driver) " a new start.") self)) ) (PUTPROPS TRUCKINR COPYRIGHT ("Xerox Corporation" 1985)) (DECLARE: DONTCOPY (FILEMAP (NIL (11408 14547 (CommodityTransportability.CheckFragility 11418 . 11667) ( CommodityTransportability.UpdateStatus 11669 . 11952) (RoadStop.BwPlace 11954 . 12611) ( RoadStop.ColorPlace 12613 . 13316) (RoadStop.DisplayIcon 13318 . 14545)) (19775 64729 ( Commodity.CanTransfer 19785 . 20548) (Commodity.CheckFragility 20550 . 20813) (Commodity.Display 20815 . 21210) (Commodity.TransferOwner 21212 . 23285) (Commodity.UpdateStatus 23287 . 23582) (Consumer.Buy 23584 . 24040) (Consumer.BuyFuel 24042 . 24172) (Consumer.CanBuy 24174 . 25464) (Consumer.DisplayData 25466 . 26686) (Consumer.DisplayIcon 26688 . 27672) (Consumer.Show 27674 . 28492) ( FragileCommodity.CheckFragility 28494 . 29462) (FragileCommodity.PartialTransfer 29464 . 29835) ( OtherRoadStop.DisplayIcon 29837 . 30630) (OtherRoadStop.Initialize 30632 . 30937) ( OtherRoadStop.ReInitialize 30939 . 31211) (OtherRoadStop.Show 31213 . 31586) ( PerishableCommodity.PartialTransfer 31588 . 31957) (PerishableCommodity.UpdateStatus 31959 . 32808) ( Producer.DisplayData 32810 . 34130) (Producer.DisplayIcon 34132 . 35052) (Producer.Sell 35054 . 35467) (Producer.SellFuel 35469 . 35596) (Producer.Show 35598 . 36416) (RoadStop.AnyVictim 36418 . 37019) ( RoadStop.BWDisplay 37021 . 39450) (RoadStop.Bandit? 39452 . 40109) (RoadStop.BanditP 40111 . 40205) ( RoadStop.BanditReady 40207 . 40605) (RoadStop.ColorDisplay 40607 . 42906) (RoadStop.Crash 42908 . 44371) (RoadStop.Display 44373 . 44711) (RoadStop.DisplayData 44713 . 44946) (RoadStop.Flash 44948 . 45474) (RoadStop.GoingPast 45476 . 46344) (RoadStop.Initialize 46346 . 46790) (RoadStop.Park 46792 . 48844) (RoadStop.Parked? 48846 . 49168) (RoadStop.Place 49170 . 49646) (RoadStop.ReInitialize 49648 . 50179) (RoadStop.RoomToPark? 50181 . 50495) (RoadStop.TimeSpent 50497 . 51047) (RoadStop.TurnsStayed 51049 . 51523) (RoadStop.Unpark 51525 . 53136) (RoadStop.Visit 53138 . 56306) (SystemTruck.Buy 56308 . 57469) (SystemTruck.CanBuy 57471 . 58877) (SystemTruck.Sell 58879 . 60302) (Truck.BuyFuel 60304 . 60844) (Truck.CanBuyFuel 60846 . 61800) (Truck.FillTank 61802 . 62977) (Truck.Initialize 62979 . 63413 ) (Truck.SellFuel 63415 . 64331) (Truck.VisitUnionHall 64333 . 64727))))) STOP