ScummVM API documentation
Ultima::Ultima2::Logic::Logic Class Reference

#include <logic.h>

Inheritance diagram for Ultima::Ultima2::Logic::Logic:
Ultima::Ultima2::Logic::DungeonLogic Ultima::Ultima2::Logic::OverworldLogic Ultima::Ultima2::Logic::SpaceLogic Ultima::Ultima2::Logic::CityCastleLogic

Public Member Functions

virtual void action (int action)
 
virtual void keypress (const Graphics::Views::KeypressMessage &msg)
 
virtual void entering ()
 
virtual bool attack (Data::Direction dir=Data::DIR_UNSPECIFIED)
 
virtual bool fire (Data::Direction dir=Data::DIR_UNSPECIFIED)
 
virtual bool steal (Data::Direction dir=Data::DIR_UNSPECIFIED)
 
virtual bool unlock (Data::Direction dir=Data::DIR_UNSPECIFIED)
 
virtual bool offer (Data::Direction dir=Data::DIR_UNSPECIFIED)
 
virtual bool transact (Data::Direction dir=Data::DIR_UNSPECIFIED)
 
void resolveDirection (Data::Direction dir)
 
virtual void completeOffer (int)
 
virtual void completeStatBoost (int)
 
virtual void tick ()
 
bool eatFood (int amount)
 
void playerDied (bool showDied=true)
 
void resumeTurn ()
 
bool trySpendGold (int amount)
 

Protected Types

enum class  DirectionPurpose {
  ATTACK , FIRE , STEAL , UNLOCK ,
  OFFER , TRANSACT
}
 

Protected Member Functions

void writeString (const Common::String &msg)
 
void writeString (const char *format,...)
 
void prompt ()
 
void alertTownGuards (int extraSlot=-1)
 
void redrawMap ()
 
void redrawStats ()
 
int getRandomNumber (int minNumber, int maxNumber)
 
int getRandomNumber (int maxNumber)
 
byte randByte ()
 
void showAttackTile (int x, int y)
 
void playFX (Data::SoundEffect fx)
 
virtual void endOfTurn ()
 
virtual void updateCreatures ()
 
virtual bool move (Data::Direction)
 
virtual bool board ()
 
virtual bool cast ()
 
virtual bool castSpell (Data::SpellType spell)
 
virtual bool descend ()
 
virtual bool enter ()
 
virtual bool get ()
 
virtual bool hyper ()
 
virtual bool igniteTorch ()
 
virtual bool jump ()
 
virtual bool klimb ()
 
virtual bool launch ()
 
virtual bool magic ()
 
virtual bool negateTime ()
 
virtual bool pass ()
 
virtual bool quit ()
 
virtual bool ready ()
 
virtual bool view ()
 
virtual bool wearArmor ()
 
virtual bool xit ()
 
virtual bool yell ()
 
virtual bool zstats ()
 

Protected Attributes

DirectionPurpose _directionPurpose = DirectionPurpose::ATTACK
 
bool _monstersSkipTurn = false
 

Detailed Description

Base class for gameplay handling logic - one virtual method per player command letter, with a default fallback body for each. Concrete subclasses per mode (overworld, city/castle, dungeon, space) override only the commands that differ there.

Member Function Documentation

◆ writeString()

void Ultima::Ultima2::Logic::Logic::writeString ( const Common::String &  msg)
protected

Dispatches some text to be shown in the Commands window

◆ prompt()

void Ultima::Ultima2::Logic::Logic::prompt ( )
protected

Triggers a prompt display in the Commands window

◆ alertTownGuards()

void Ultima::Ultima2::Logic::Logic::alertTownGuards ( int  extraSlot = -1)
protected

Alerts nearby town guards (slots 0-7, plus optionally the specific slot just interacted with) after an attack or theft. A no-op on the overworld (_mapType == 0)

◆ redrawMap()

void Ultima::Ultima2::Logic::Logic::redrawMap ( )
protected

Signal the map to redraw

◆ redrawStats()

void Ultima::Ultima2::Logic::Logic::redrawStats ( )
protected

Signal the stats to redraw

◆ getRandomNumber()

int Ultima::Ultima2::Logic::Logic::getRandomNumber ( int  minNumber,
int  maxNumber 
)
protected

Returns a random number

◆ randByte()

byte Ultima::Ultima2::Logic::Logic::randByte ( )
protected

Returns the next byte from the game's random number generator

◆ showAttackTile()

void Ultima::Ultima2::Logic::Logic::showAttackTile ( int  x,
int  y 
)
protected

Has the currently focused map view briefly flash the attack sprite over a map position - a hit indicator, pausing before returning. See AttackTileMessage

◆ playFX()

void Ultima::Ultima2::Logic::Logic::playFX ( Data::SoundEffect  fx)
protected

Plays a short PC speaker sound effect

◆ endOfTurn()

virtual void Ultima::Ultima2::Logic::Logic::endOfTurn ( )
protectedvirtual

Handles end of turn logic

◆ updateCreatures()

virtual void Ultima::Ultima2::Logic::Logic::updateCreatures ( )
inlineprotectedvirtual

◆ castSpell()

virtual bool Ultima::Ultima2::Logic::Logic::castSpell ( Data::SpellType  spell)
protectedvirtual

Applies the effect of a spell that's just been cast

Reimplemented in Ultima::Ultima2::Logic::DungeonLogic.

◆ entering()

virtual void Ultima::Ultima2::Logic::Logic::entering ( )
inlinevirtual

◆ resolveDirection()

void Ultima::Ultima2::Logic::Logic::resolveDirection ( Data::Direction  dir)

Called by the Direction interaction once a direction has been chosen, dispatching to whichever command requested it (see _directionPurpose). Resumes the turn if the command reports it's now complete.

◆ completeOffer()

virtual void Ultima::Ultima2::Logic::Logic::completeOffer ( int  )
inlinevirtual

Called once a digit has been chosen by the OfferGold interaction

Reimplemented in Ultima::Ultima2::Logic::CityCastleLogic.

◆ completeStatBoost()

virtual void Ultima::Ultima2::Logic::Logic::completeStatBoost ( int  )
inlinevirtual

Called once an attribute has been chosen by the StatBoost interaction (1 to 6, anything else being none of them)

Reimplemented in Ultima::Ultima2::Logic::CityCastleLogic.

◆ tick()

virtual void Ultima::Ultima2::Logic::Logic::tick ( )
inlinevirtual

Called once per game frame for any logic updates

◆ eatFood()

bool Ultima::Ultima2::Logic::Logic::eatFood ( int  amount)

Uses up some food, given in hundredths of a unit, or half that if the option for less hunger is on. Returns false if food ran out

◆ playerDied()

void Ultima::Ultima2::Logic::Logic::playerDied ( bool  showDied = true)

Handles the player dying - clears their resources and returns to the title screen

◆ resumeTurn()

void Ultima::Ultima2::Logic::Logic::resumeTurn ( )
inline

Resumes end of turn processing after a command deferred it (returned false from action()) to run some sub-interaction first

◆ trySpendGold()

bool Ultima::Ultima2::Logic::Logic::trySpendGold ( int  amount)

Attempts to deduct gold; prints a failure message and returns false if the player can't afford it. Public since interactions (shop purchases, offerings) call this directly


The documentation for this class was generated from the following file: