20 #include <QTextStream>
31 case WOOD:
return QObject::tr(
"Wooden board");
33 case STONE:
return QObject::tr(
"Stone slab");
34 default:
return QObject::tr(
"Plate (%1)").arg(
SubName(
Sub()));
45 case STONE:
return QObject::tr(
"Rock with ledges");
46 case GREENERY:
return QObject::tr(
"Liana");
47 default:
return QObject::tr(
"Ladder (%1)").arg(
SubName(
Sub()));
61 *delete_block =
false;
79 default:
switch ( qrand() % 20 ) {
118 case STONE:
return tr(
"Lava");
120 case A_MEAT:
return tr(
"Blood");
127 int i=
X(), j=
Y(), k=
Z();
137 if ( not world->
InBounds(i, j) )
return;
139 const int sub_near = world->
GetBlock(i, j, k)->
Sub();
140 if ( (
AIR == sub_near
160 || (
FIRE==own_sub && (
167 ||
PAPER==ground ) );
173 case FIRE:
return tr(
"Fire");
174 default:
return tr(
"Plant (%1)").arg(
SubName(
Sub()));
228 Bush::Bush(QDataStream & str,
const int kind,
const int sub) :
239 case SAND:
return - 1;
250 switch ( qrand()%60 ) {
261 moved_in_this_turn =
false;
266 moved_in_this_turn =
false;
314 return QString(
"%1 (%2)").
315 arg(
locked ? tr(
"Locked door") : tr(
"Door")).
336 Door::Door(QDataStream & str,
const int kind,
const int sub) :
347 if ( who !=
nullptr ) {
349 tr(
"Outer time is %1.").arg(QTime::currentTime().toString()) :
392 return ( notify_flag>1 ) ?
395 switch ( current_time ) {
396 default: --notify_flag;
break;
402 if ( notify_flag > 0 ) {
413 QTextStream txt_stream(&str);
419 alarmTime += alarm_hour*60;
450 case PAPER:
return QObject::tr(
"Paper page");
451 case GLASS:
return QObject::tr(
"Screen");
452 default:
return QObject::tr(
"Sign (%1)").arg(
SubName(
Sub()));
481 who->
ReceiveSignal(QObject::tr(
"Set title to this map first."));
489 if ( not map_file.open(QIODevice::ReadWrite | QIODevice::Text) ) {
494 const int FILE_SIZE_CHARS = 31 + 1;
495 if ( 0 == map_file.size() ) {
496 const char header[FILE_SIZE_CHARS+1] =
497 "+-----------------------------+\n";
498 const char body[FILE_SIZE_CHARS+1] =
500 map_file.write(header, FILE_SIZE_CHARS);
501 for (
int i=0; i<FILE_SIZE_CHARS-3; ++i) {
502 map_file.write(body, FILE_SIZE_CHARS);
504 map_file.write(header, FILE_SIZE_CHARS);
508 const int border_dist = (FILE_SIZE_CHARS - 1) / 2;
510 ( qAbs(lati -
latiStart ) > border_dist ) ||
522 map_file.putChar(
'@');
524 map_file.seek(FILE_SIZE_CHARS * (FILE_SIZE_CHARS - 1));
525 map_file.write(
" @ = ");
542 Map::Map(QDataStream & str,
const int kind,
const int sub) :
543 Text(str, kind, sub),
593 return tr(
"Telegraph (%1)").arg(
SubName(
Sub()));
608 const QString note =
GetNote();
650 case IRON:
return QObject::tr(
"Compass");
651 default:
return QObject::tr(
"Informer (%1)").arg(
SubName(
Sub()));
bool Move(int x, int y, int z, dirs dir)
Check and move.
int TimeOfDay() const
This returns seconds from start of current day.
void SendSignalAround(QString) const
QString FullName() const override
const int MAX_DURABILITY
10 bits to store durability in file, signed.
wearable Wearable() const override
void SaveAttributes(QDataStream &) const override
Block * DropAfterDamage(bool *delete_block) override
Should return dropped block.
QString FullName() const override
virtual void SaveAttributes(QDataStream &) const
quint16 noteId
To convert DAMAGE_PUSH_UP...WEST to corresponding direction.
void Mend(int plus)
Increase durability, no more than MAX_DURABILITY.
long Latitude() const
Returns x (column) shred coordinate on world map.
QString FullName() const override
void ActFrequent() override
QString FullName() const override
BlockManager block_manager
static QString SubName(int sub)
Returns translated substance name.
push_reaction PushResult(dirs) const override
static QString SubNameUpper(int sub)
Returns translated substance name with first upper letter.
World provides global physics and shred connection.
Block * DropAfterDamage(bool *delete_block) override
Should return dropped block.
int ShouldAct() const override
int ShouldAct() const override
virtual void Damage(int dmg, int dmg_kind)
int LightRadius() const override
void DoRareAction() override
push_reaction PushResult(dirs) const override
usage_types Use(Block *user) override
void DoRareAction() override
Block * Normal(int sub) const
Use this to receive a pointer to normal block.
QString FullName() const override
wearable Wearable() const override
usage_types Use(Block *who) override
virtual int Weight() const
int ShouldAct() const override
int Weight() const override
static dirs Anti(dirs dir)
void Damage(int dmg, int dmg_kind) override
wearable Wearable() const override
virtual bool Get(Block *block, int start=0)
Returns true on success.
void SaveAttributes(QDataStream &out) const override
static sub_groups GetSubGroup(int sub)
bool Gravitate(int range, int down, int up, int calmness)
virtual Inventory * HasInventory()
void DoRareAction() override
void SaveAttributes(QDataStream &) const override
static bool IsBase(int ownsub, int ground)
bool Inscribe(QString) override
Returns true on success.
int ShouldAct() const override
void Damage(int dmg, int dmg_kind) override
usage_types Use(Block *who) override
push_reaction PushResult(dirs) const override
int ShouldAct() const override
QString FullName() const override
void ActFrequent() override
void Damage(int dmg, int dmg_kind) override
void Jump(int x, int y, int z, dirs dir)
bool Inscribe(QString) override
Returns true on success.
inner_actions ActInner() override
wearable Wearable() const override
void DoRareAction() override
inner_actions
See Shred::PhysEventsRare() for details.
void ReceiveSignal(QString) override
Receive text signal.
QString FullName() const override
static dirs MakeDirFromDamage(int damage_kind)
bool Inscribe(QString) override
Returns true on success.
usage_types Use(Block *who) override
Block * GetBlock(int x, int y, int z) const
bool Inscribe(QString) override
Returns true on success.
wearable Wearable() const override
Block * DropAfterDamage(bool *delete_block) override
Should return dropped block.
QString FullName() const override
void DamageAround() const
QString FullName() const override
QString FullName() const override
usage_types Use(Block *who) override
Block * DropAfterDamage(bool *delete_block) override
Should return dropped block.
int LightRadius() const override
bool Catchable() const override
const WorldMap * GetMap() const
static QString DirString(dirs)
void Damage(int dmg, int dmg_kind) override
usage_types Use(Block *who) override
void SaveAttributes(QDataStream &out) const override
wearable Wearable() const override
void DoRareAction() override
void Damage(int dmg, int dmg_kind) override
int DamageKind() const override
static Block * NewBlock(int kind, int sub)
Use this to receive a pointer to new not-normal block.
int DamageKind() const override
int ShouldAct() const override
int NutritionalValue(subs) const override
usage_types Use(Block *who) override
push_reaction PushResult(dirs) const override
static QString sharedMessage
long Longitude() const
Returns y (line) shred coordinate on world map.
void ReceiveSignal(QString) override
Receive text signal.
char TypeOfShred(long longi, long lati) const
void ReceiveSignal(QString) override
Receive text signal.
virtual int Weight() const
void DestroyAndReplace(int x, int y, int z)
Does not check target block durability.
usage_types Use(Block *who) override
inner_actions ActInner() override
void Push(int x, int y, int z, int push_direction)
QString FullName() const override
int DamageLevel() const override
virtual Active * ActiveBlock()
inner_actions ActInner() override
Provides block ability to contain other blocks inside.
void Damage(int dmg, int dmg_kind) override
bool InBounds(int x, int y) const
bool Build(Block *thing, int x, int y, int z, int dir=UP, Block *who=nullptr, bool anyway=false)
Returns true on successfull build, otherwise false.
Inventory * HasInventory() override
void SaveAttributes(QDataStream &out) const override
int GetDurability() const
int Weight() const override
void Break()
Set durability to null.
QString FullName() const override
int Weight() const override
int Attractive(int sub) const override
inner_actions ActInner() override
QString FullName() const override
virtual void ReceiveSignal(QString)
Receive text signal.
inner_actions ActInner() override
Block without special physics and attributes.
qint64 longiStart
coordinates map titled in. also ~center.
Telegraph(int sub, int id)
bool IsSubAround(int sub) const
Returns true if there is at least 1 block of substance sub around.
virtual void SaveAttributes(QDataStream &out) const
virtual bool Inscribe(QString str)
Returns true on success.
QString WorldName() const
int Weight() const override
usage_types UseOnShredMove(Block *who) override
int Enlightened(int x, int y, int z) const