freg  0.3
Free-Roaming Elementary Game
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
blocks.cpp
Go to the documentation of this file.
1  /* freg, Free-Roaming Elementary Game with open and interactive world
2  * Copyright (C) 2012-2014 Alexander 'mmaulwurff' Kromm
3  * mmaulwurff@gmail.com
4  *
5  * This file is part of FREG.
6  *
7  * FREG is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * FREG is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with FREG. If not, see <http://www.gnu.org/licenses/>. */
19 
20 #include <QTextStream>
21 #include <QFile>
22 #include <QTime>
23 #include "blocks.h"
24 #include "World.h"
25 #include "Shred.h"
26 #include "BlockManager.h"
27 
28 // Plate::
29  QString Plate::FullName() const {
30  switch ( Sub() ) {
31  case WOOD: return QObject::tr("Wooden board");
32  case MOSS_STONE:
33  case STONE: return QObject::tr("Stone slab");
34  default: return QObject::tr("Plate (%1)").arg(SubName(Sub()));
35  }
36  }
37 
38  int Plate::Weight() const { return Block::Weight()/4; }
40 
41 // Ladder::
42  QString Ladder::FullName() const {
43  switch ( Sub() ) {
44  case MOSS_STONE:
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()));
48  }
49  }
50 
51  bool Ladder::Catchable() const { return true; }
52  int Ladder::Weight() const { return Block::Weight()*3; }
54 
55  Block * Ladder::DropAfterDamage(bool * const delete_block) {
56  Block * const pile = BlockManager::NewBlock(BOX, DIFFERENT);
57  if ( STONE==Sub() || MOSS_STONE==Sub() ) {
59  } else {
60  pile->HasInventory()->Get(this);
61  *delete_block = false;
62  }
63  return pile;
64  }
65 
66 // Liquid::
68  if ( not IsSubAround(Sub()) || Sub()==SUB_CLOUD ) {
70  if ( GetDurability() <= 0 ) {
71  GetWorld()->DestroyAndReplace(X(), Y(), Z());
72  return;
73  }
74  }
75  switch ( Sub() ) {
76  case SUB_CLOUD: return;
77  case ACID:
78  case STONE: DamageAround(); // no break;
79  default: switch ( qrand() % 20 ) {
80  case 0: GetWorld()->Move(X(), Y(), Z(), NORTH); break;
81  case 1: GetWorld()->Move(X(), Y(), Z(), SOUTH); break;
82  case 2: GetWorld()->Move(X(), Y(), Z(), EAST ); break;
83  case 3: GetWorld()->Move(X(), Y(), Z(), WEST ); break;
84  } break;
85  }
86  }
87 
88  int Liquid::DamageKind() const {
89  switch ( Sub() ) {
90  default: return DAMAGE_NO;
91  case ACID: return DAMAGE_ACID;
92  case STONE: return DAMAGE_HEAT;
93  }
94  }
95 
96  int Liquid::DamageLevel() const { return MAX_DURABILITY / 20; }
97 
98  int Liquid::ShouldAct() const { return FREQUENT_RARE; }
99  int Liquid::LightRadius() const { return ( STONE==Sub() ) ? 3 : 0; }
100  bool Liquid::Inscribe(QString) { return false; }
104 
105  void Liquid::Damage(const int dmg, const int dmg_kind) {
106  if ( dmg_kind < DAMAGE_PUSH_UP ) {
107  Falling::Damage(dmg, dmg_kind);
108  }
109  }
110 
112  return block_manager.Normal( ( Sub() == STONE ) ?
113  STONE : AIR);
114  }
115 
116  QString Liquid::FullName() const {
117  switch ( Sub() ) {
118  case STONE: return tr("Lava");
119  case H_MEAT:
120  case A_MEAT: return tr("Blood");
121  default: return SubNameUpper(Sub());
122  }
123  }
124 
125 // Grass::
127  int i=X(), j=Y(), k=Z();
128  // increase this if grass grows too fast
129  switch ( qrand() % (FIRE==Sub() ? 4 : SECONDS_IN_HOUR*4) ) {
130  case 0: ++i; break;
131  case 1: --i; break;
132  case 2: ++j; break;
133  case 3: --j; break;
134  default: return;
135  }
136  World * const world = GetWorld();
137  if ( not world->InBounds(i, j) ) return;
138  if ( FIRE == Sub() || world->Enlightened(i, j, k) ) {
139  const int sub_near = world->GetBlock(i, j, k)->Sub();
140  if ( (AIR == sub_near
141  && IsBase(Sub(), world->GetBlock(i, j, k-1)->Sub() ) )
142  || ( IsBase(Sub(), sub_near)
143  && AIR == world->GetBlock(i, j, ++k)->Sub() ) )
144  {
145  world->Build(BlockManager::NewBlock(GRASS, Sub()), i, j, k);
146  }
147  }
148  if ( not IsBase(Sub(), world->GetBlock(X(), Y(), Z()-1)->Sub()) ) {
149  world->DestroyAndReplace(X(), Y(), Z());
150  } else if ( FIRE == Sub() ) {
151  DamageAround();
152  if ( qrand()%10 || IsSubAround(WATER) ) {
153  Damage(2, DAMAGE_FREEZE);
154  }
155  }
156  }
157 
158  bool Grass::IsBase(const int own_sub, const int ground) {
159  return ( GREENERY==own_sub && SOIL==ground )
160  || ( FIRE==own_sub && (
161  WOOD==ground
162  || GREENERY==ground
163  || H_MEAT==ground
164  || A_MEAT==ground
165  || SUB_NUT==ground
166  || ROSE==ground
167  || PAPER==ground ) );
168  }
169 
170  QString Grass::FullName() const {
171  switch ( Sub() ) {
172  case GREENERY: return tr("Grass");
173  case FIRE: return tr("Fire");
174  default: return tr("Plant (%1)").arg(SubName(Sub()));
175  }
176  }
177 
178  int Grass::ShouldAct() const { return FREQUENT_RARE; }
179  int Grass::LightRadius() const { return (FIRE == Sub()) ? 5 : 0; }
182 
183  int Grass::DamageKind() const {
184  return (Sub() == FIRE) ? DAMAGE_HEAT : DAMAGE_NO;
185  }
186 
187 // Bush::
188  int Bush::ShouldAct() const { return FREQUENT_RARE; }
189  void Bush::ReceiveSignal(const QString str) { Active::ReceiveSignal(str); }
190  int Bush::Weight() const { return Inventory::Weight()+Block::Weight(); }
191  QString Bush::FullName() const { return tr("Bush"); }
193  Inventory * Bush::HasInventory() { return this; }
195 
197  if ( 0 == qrand()%(SECONDS_IN_HOUR*4) ) {
199  }
200  }
201 
202  void Bush::Damage(const int dmg, const int dmg_kind) {
203  if ( dmg_kind >= DAMAGE_PUSH_UP ) {
204  Push(X(), Y(), Z(), dmg_kind);
205  } else {
206  Block::Damage(dmg, dmg_kind);
207  }
208  }
209 
211  Block * const pile = BlockManager::NewBlock(BOX, DIFFERENT);
212  Inventory * const pile_inv = pile->HasInventory();
213  pile_inv->Get(BlockManager::NewBlock(WEAPON, WOOD));
215  return pile;
216  }
217 
218  void Bush::SaveAttributes(QDataStream & out) const {
221  }
222 
223  Bush::Bush(const int kind, const int sub) :
224  Active(kind, sub),
225  Inventory(BUSH_SIZE)
226  {}
227 
228  Bush::Bush(QDataStream & str, const int kind, const int sub) :
229  Active(str, kind, sub),
230  Inventory(str, BUSH_SIZE)
231  {}
232 
233 // Rabbit::
234  int Rabbit::Attractive(const int sub) const {
235  switch ( sub ) {
236  case GREENERY: return 1;
237  case H_MEAT: return -16;
238  case A_MEAT: return - 1;
239  case SAND: return - 1;
240  default: return 0;
241  }
242  }
243 
245  // eat sometimes
246  if ( SECONDS_IN_DAY/2 > Satiation() ) {
247  EatGrass();
248  }
249  if ( not moved_in_this_turn ) {
250  switch ( qrand()%60 ) {
251  case 0: SetDir(NORTH); break;
252  case 1: SetDir(SOUTH); break;
253  case 2: SetDir(EAST); break;
254  case 3: SetDir(WEST); break;
255  default: if ( Gravitate(4, 1, 3, 4) ) {
256  if ( qrand()%2 ) {
257  GetWorld()->Jump(X(), Y(), Z(), GetDir());
258  } else {
259  GetWorld()->Move(X(), Y(), Z(), GetDir());
260  }
261  moved_in_this_turn = false; // for next turn
262  } return;
263  }
264  GetWorld()->Move(X(), Y(), Z(), GetDir());
265  }
266  moved_in_this_turn = false; // for next turn
268  }
269 
270  QString Rabbit::FullName() const { return tr("Herbivore"); }
271 
273  if ( Gravitate(2, 1, 2, 4) ) {
274  if ( qrand()%2 ) {
275  world->Jump(X(), Y(), Z(), GetDir());
276  } else {
277  world->Move(X(), Y(), Z(), GetDir());
278  }
279  moved_in_this_turn = true;
280  }
281  }
282 
283  int Rabbit::NutritionalValue(const subs sub) const {
284  return ( GREENERY == sub ) ? SECONDS_IN_HOUR*4 : 0;
285  }
286 
287 // Door::
288  void Door::Damage(const int dmg, const int dmg_kind) {
289  if ( dmg_kind >= DAMAGE_PUSH_UP
290  && not shifted
291  && not locked
292  && World::Anti(GetDir()) != MakeDirFromDamage(dmg_kind) )
293  {
294  movable = MOVABLE;
295  shifted = GetWorld()->Move(X(), Y(), Z(), GetDir());
297  }
298  Block::Damage(dmg, dmg_kind);
299  }
300 
302  if ( shifted ) {
303  World * const world = GetWorld();
304  movable = MOVABLE;
305  shifted = !world->Move(X(), Y(), Z(), World::Anti(GetDir()));
307  }
308  }
309 
310  int Door::ShouldAct() const { return FREQUENT_SECOND; }
312 
313  QString Door::FullName() const {
314  return QString("%1 (%2)").
315  arg(locked ? tr("Locked door") : tr("Door")).
316  arg(SubName(Sub()));
317  }
318 
320  locked = !locked;
321  return USAGE_TYPE_INNER;
322  }
323 
324  void Door::SaveAttributes(QDataStream & out) const {
326  out << shifted << locked;
327  }
328 
329  Door::Door(const int kind, const int sub) :
330  Active(kind, sub, ( STONE==sub || MOSS_STONE==sub ) ?
332  shifted(false),
333  locked(false)
334  {}
335 
336  Door::Door(QDataStream & str, const int kind, const int sub) :
337  Active(str, kind, sub, ( STONE==sub || MOSS_STONE==sub ) ?
339  shifted(),
340  locked()
341  {
342  str >> shifted >> locked;
343  }
344 
345 // Clock::
346  usage_types Clock::Use(Block * const who) {
347  if ( who != nullptr ) {
348  who->ReceiveSignal( (GetNote().left(4) == "real") ?
349  tr("Outer time is %1.").arg(QTime::currentTime().toString()) :
350  GetWorld()->TimeOfDayStr() );
351  } else {
353  }
354  return USAGE_TYPE_INNER;
355  }
356 
357  QString Clock::FullName() const {
358  return ( Sub() == EXPLOSIVE ) ?
359  tr("Bomb") :
360  tr("Clock (%1)").arg(SubName(Sub()));
361  }
362 
363  void Clock::Damage(int, const int dmg_kind) {
364  if ( dmg_kind >= DAMAGE_PUSH_UP ) {
365  Use(nullptr);
366  } else {
367  alarmTime = timerTime = -1;
368  Break();
369  }
370  }
371 
372  int Clock::ShouldAct() const { return FREQUENT_RARE; }
373  int Clock::Weight() const { return Block::Weight()/10; }
375 
377  const int current_time = GetWorld()->TimeOfDay();
378  int notify_flag = 1;
379  if ( alarmTime == current_time ) {
380  Block::Inscribe(tr("Alarm. %1").arg(GetWorld()->TimeOfDayStr()));
381  ++notify_flag;
382  } else if ( timerTime > 0 ) {
383  --timerTime;
384  Block::Inscribe(QString().setNum(timerTime));
385  } else if ( timerTime == 0 ) {
386  timerTime = -1;
387  Block::Inscribe(tr("Timer fired. %1").
388  arg(GetWorld()->TimeOfDayStr()));
389  ++notify_flag;
390  }
391  if ( Sub()==EXPLOSIVE ) {
392  return ( notify_flag>1 ) ?
394  }
395  switch ( current_time ) {
396  default: --notify_flag; break;
397  case END_OF_NIGHT: Inscribe(tr("Morning has come.")); break;
398  case END_OF_MORNING: Inscribe(tr("Day has come.")); break;
399  case END_OF_NOON: Inscribe(tr("Evening has come.")); break;
400  case END_OF_EVENING: Inscribe(tr("Night has come.")); break;
401  }
402  if ( notify_flag > 0 ) {
403  Use(nullptr);
404  return INNER_ACTION_MESSAGE;
405  } else {
406  return INNER_ACTION_ONLY;
407  }
408  }
409 
410  bool Clock::Inscribe(QString str) {
411  Block::Inscribe(str);
412  char c;
413  QTextStream txt_stream(&str);
414  txt_stream >> c;
415  switch ( c ) {
416  case 'a': {
417  int alarm_hour;
418  txt_stream >> alarm_hour >> alarmTime;
419  alarmTime += alarm_hour*60;
420  timerTime = -1;
421  } break;
422  case 't':
423  txt_stream >> timerTime;
424  alarmTime = -1;
425  break;
426  default:
427  alarmTime = timerTime = -1;
428  break;
429  }
430  return true;
431  }
432 
433  void Clock::SaveAttributes(QDataStream & str) const {
434  str << alarmTime << timerTime;
435  }
436 
437  Clock::Clock(const int kind, const int sub) :
438  Active(kind, sub, NONSTANDARD)
439  {}
440 
441  Clock::Clock (QDataStream & str, const int kind, const int sub) :
442  Active(str, kind, sub, NONSTANDARD)
443  {
444  str >> alarmTime >> timerTime;
445  }
446 
447 // Text::
448  QString Text::FullName() const {
449  switch ( Sub() ) {
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()));
453  }
454  }
455 
456  usage_types Text::Use(Block * const who) {
457  if ( noteId == 0 ) {
458  who->ReceiveSignal(QObject::tr("Nothing is written here."));
459  return USAGE_TYPE_INNER;
460  } else {
461  return USAGE_TYPE_READ;
462  }
463  }
464 
465  bool Text::Inscribe(const QString str) {
466  if ( '.' != str.at(0) && (noteId == 0 || GLASS == Sub()) ) {
467  Block::Inscribe(str);
468  return true;
469  } else {
470  return false;
471  }
472  }
473 
474 // Map::
476  QString Map::FullName() const { return QObject::tr("Map"); }
477  usage_types Map::UseOnShredMove(Block * const user) { return Use(user); }
478 
479  usage_types Map::Use(Block * const who) {
480  if ( noteId == 0 ) {
481  who->ReceiveSignal(QObject::tr("Set title to this map first."));
482  return USAGE_TYPE_INNER;
483  } // else:
484  if ( who == nullptr ) return USAGE_TYPE_READ;
485  const Active * const active = who->ActiveBlock();
486  if ( active == nullptr ) return USAGE_TYPE_READ;
487  QFile map_file(home_path + active->GetWorld()->WorldName()
488  + "/texts/" + GetNote());
489  if ( not map_file.open(QIODevice::ReadWrite | QIODevice::Text) ) {
490  return USAGE_TYPE_READ;
491  }
492  const long lati = active->GetShred()->Latitude();
493  const long longi = active->GetShred()->Longitude();
494  const int FILE_SIZE_CHARS = 31 + 1;
495  if ( 0 == map_file.size() ) { // new map
496  const char header[FILE_SIZE_CHARS+1] =
497  "+-----------------------------+\n";
498  const char body[FILE_SIZE_CHARS+1] =
499  "| |\n";
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);
503  }
504  map_file.write(header, FILE_SIZE_CHARS);
505  longiStart = longi;
506  latiStart = lati;
507  }
508  const int border_dist = (FILE_SIZE_CHARS - 1) / 2;
509  if (
510  ( qAbs(lati - latiStart ) > border_dist ) ||
511  ( qAbs(longi - longiStart) > border_dist ) )
512  {
513  return USAGE_TYPE_READ;
514  }
515  if ( savedChar ) {
516  map_file.seek(savedShift);
517  map_file.putChar(savedChar);
518  }
519  map_file.seek( savedShift = FILE_SIZE_CHARS *
520  (longi - longiStart + border_dist ) +
521  lati - latiStart + border_dist );
522  map_file.putChar('@');
523  savedChar = active->GetWorld()->GetMap()->TypeOfShred(longi, lati);
524  map_file.seek(FILE_SIZE_CHARS * (FILE_SIZE_CHARS - 1));
525  map_file.write(" @ = ");
526  map_file.putChar(savedChar);
527  return USAGE_TYPE_READ;
528  } // usage_types Map::Use(Block * who)
529 
530  void Map::SaveAttributes(QDataStream & out) const {
531  out << longiStart << latiStart << savedShift << savedChar;
532  }
533 
534  Map::Map(const int kind, const int sub) :
535  Text(kind, sub),
536  longiStart(),
537  latiStart(),
538  savedShift(),
539  savedChar(0)
540  {}
541 
542  Map::Map(QDataStream & str, const int kind, const int sub) :
543  Text(str, kind, sub),
544  longiStart(),
545  latiStart(),
546  savedShift(),
547  savedChar()
548  {
549  str >> longiStart >> latiStart >> savedShift >> savedChar;
550  }
551 
552 // Bell:: section
554 
555  void Bell::Damage(int, int) {
556  SendSignalAround(tr("^ Ding-ding! ^"));
557  Break();
558  }
559 
560  QString Bell::FullName() const {
561  return tr("Bell (%1)").arg(SubName(Sub()));
562  }
563 
565  SendSignalAround(tr("^ Ding! ^"));
566  return USAGE_TYPE_INNER;
567  }
568 
569 // Telegraph:: section
570  QString Telegraph::sharedMessage;
571 
572  Telegraph::Telegraph(const int sub, const int id) :
573  Active(sub, id, BLOCK_OPAQUE),
574  isReceiver(true)
575  {}
576 
577  Telegraph::Telegraph(QDataStream & str, const int sub, const int id) :
578  Active(str, sub, id),
579  isReceiver()
580  {
581  str >> isReceiver;
582  }
583 
584  void Telegraph::SaveAttributes(QDataStream & str) const {
585  str << isReceiver;
586  }
587 
588  int Telegraph::ShouldAct() const { return FREQUENT_RARE; }
589  void Telegraph::ReceiveSignal(const QString str) { Inscribe(str); }
591 
592  QString Telegraph::FullName() const {
593  return tr("Telegraph (%1)").arg(SubName(Sub()));
594  }
595 
596  bool Telegraph::Inscribe(const QString str) {
597  isReceiver = false;
598  return Block::Inscribe(str);
599  }
600 
602  isReceiver = not isReceiver;
603  return USAGE_TYPE_INNER;
604  }
605 
607  if ( isReceiver ) {
608  const QString note = GetNote();
609  if ( note != sharedMessage && not sharedMessage.isEmpty() ) {
612  return INNER_ACTION_MESSAGE;
613  }
614  } else {
616  isReceiver = true;
617  }
618  return INNER_ACTION_ONLY;
619  }
620 
621 // MedKit:: section
622  QString MedKit::FullName() const { return QObject::tr("MedKit"); }
624 
625  usage_types MedKit::Use(Block * const user) {
626  if ( user
627  && GROUP_MEAT == GetSubGroup(user->Sub())
628  && GetDurability() > MAX_DURABILITY/10 )
629  {
630  user->Mend(MAX_DURABILITY/10);
632  }
633  return USAGE_TYPE_INNER;
634  }
635 
636 // Informer:: section
638 
640  switch ( Sub() ) {
641  case IRON: user->ReceiveSignal(QString("Your direction: %1.").
642  arg(DirString(user->GetDir()).toLower())); break;
643  default: break;
644  }
645  return USAGE_TYPE_INNER;
646  }
647 
648  QString Informer::FullName() const {
649  switch ( Sub() ) {
650  case IRON: return QObject::tr("Compass");
651  default: return QObject::tr("Informer (%1)").arg(SubName(Sub()));
652  }
653  }
bool Move(int x, int y, int z, dirs dir)
Check and move.
Definition: World.cpp:375
int X() const
Definition: Active.cpp:158
int Satiation() const
Definition: Animal.cpp:66
int TimeOfDay() const
This returns seconds from start of current day.
Definition: World.cpp:59
void SendSignalAround(QString) const
Definition: Active.cpp:106
QString FullName() const override
Definition: blocks.cpp:592
const int MAX_DURABILITY
10 bits to store durability in file, signed.
Definition: World.h:43
wearable Wearable() const override
Definition: blocks.cpp:590
void SaveAttributes(QDataStream &) const override
Definition: blocks.cpp:433
Block * DropAfterDamage(bool *delete_block) override
Should return dropped block.
Definition: blocks.cpp:55
QString FullName() const override
Definition: blocks.cpp:116
virtual void SaveAttributes(QDataStream &) const
Definition: Block.cpp:307
quint16 noteId
To convert DAMAGE_PUSH_UP...WEST to corresponding direction.
Definition: Block.h:169
void Mend(int plus)
Increase durability, no more than MAX_DURABILITY.
Definition: Block.cpp:238
quint16 savedShift
Definition: blocks.h:195
16
Definition: header.h:176
10
Definition: header.h:170
3
Definition: header.h:90
void SetDir(int dir)
Definition: Block.cpp:269
long Latitude() const
Returns x (column) shred coordinate on world map.
Definition: Shred.cpp:60
QString FullName() const override
Definition: blocks.cpp:191
const QString home_path
Definition: main.cpp:50
Clock(int sub, int id)
Definition: blocks.cpp:437
void ActFrequent() override
Definition: blocks.cpp:272
QString FullName() const override
Definition: blocks.cpp:170
Definition: header.h:99
BlockManager block_manager
29
Definition: header.h:189
push_reaction
Definition: header.h:95
static QString SubName(int sub)
Returns translated substance name.
Definition: Block.cpp:69
push_reaction PushResult(dirs) const override
Definition: blocks.cpp:311
27
Definition: header.h:187
World * world
Definition: World.cpp:32
6
Definition: header.h:121
28
Definition: header.h:188
static QString SubNameUpper(int sub)
Returns translated substance name with first upper letter.
Definition: Block.cpp:77
World provides global physics and shred connection.
Definition: World.h:52
Block * DropAfterDamage(bool *delete_block) override
Should return dropped block.
Definition: blocks.cpp:181
int ShouldAct() const override
Definition: blocks.cpp:588
int ShouldAct() const override
Definition: blocks.cpp:188
virtual void Damage(int dmg, int dmg_kind)
Definition: Block.cpp:117
int LightRadius() const override
Definition: blocks.cpp:99
void DoRareAction() override
Definition: Animal.cpp:47
push_reaction PushResult(dirs) const override
Definition: blocks.cpp:53
usage_types Use(Block *user) override
Definition: blocks.cpp:625
short Z() const
Definition: Xyz.cpp:30
void DoRareAction() override
Definition: blocks.cpp:67
bool shifted
Definition: blocks.h:142
Definition: header.h:100
Block * Normal(int sub) const
Use this to receive a pointer to normal block.
QString FullName() const override
Definition: blocks.cpp:313
wearable Wearable() const override
Definition: blocks.cpp:553
usage_types Use(Block *who) override
Definition: blocks.cpp:479
virtual int Weight() const
Definition: Block.cpp:242
int ShouldAct() const override
Definition: blocks.cpp:310
int Weight() const override
Definition: blocks.cpp:373
static dirs Anti(dirs dir)
Definition: World.cpp:191
void Damage(int dmg, int dmg_kind) override
Definition: blocks.cpp:555
wearable Wearable() const override
Definition: blocks.cpp:374
2
Definition: header.h:89
Map(int sub, int id)
Definition: blocks.cpp:534
void EatGrass()
Definition: Animal.cpp:92
virtual bool Get(Block *block, int start=0)
Returns true on success.
Definition: Inventory.cpp:78
Bush(int sub, int id)
Definition: blocks.cpp:223
QString FullName() const override
Definition: blocks.cpp:648
void SaveAttributes(QDataStream &out) const override
Definition: blocks.cpp:324
dirs GetDir() const
Definition: Block.cpp:231
static sub_groups GetSubGroup(int sub)
Definition: Block.cpp:275
bool Gravitate(int range, int down, int up, int calmness)
Definition: Active.cpp:178
Door(int sub, int id)
Definition: blocks.cpp:329
4
Definition: header.h:91
virtual Inventory * HasInventory()
Definition: Block.cpp:224
qint8 savedChar
Definition: blocks.h:196
bool isReceiver
Definition: blocks.h:229
6
Definition: header.h:166
void DoRareAction() override
Definition: blocks.cpp:196
int alarmTime
Definition: blocks.h:166
void SaveAttributes(QDataStream &) const override
Definition: blocks.cpp:584
static bool IsBase(int ownsub, int ground)
Definition: blocks.cpp:158
7 (hominid meat)
Definition: header.h:167
bool Inscribe(QString) override
Returns true on success.
Definition: blocks.cpp:465
push_reaction movable
Definition: blocks.h:144
int ShouldAct() const override
Definition: blocks.cpp:372
5
Definition: Block.h:44
void Damage(int dmg, int dmg_kind) override
Definition: blocks.cpp:288
usage_types Use(Block *who) override
Definition: blocks.cpp:601
Shred * GetShred() const
Definition: Active.cpp:139
push_reaction PushResult(dirs) const override
Definition: blocks.cpp:39
int ShouldAct() const override
Definition: blocks.cpp:178
QString FullName() const override
Definition: blocks.cpp:357
void ActFrequent() override
Definition: blocks.cpp:301
int timerTime
Definition: blocks.h:167
void Damage(int dmg, int dmg_kind) override
Definition: blocks.cpp:105
void Jump(int x, int y, int z, dirs dir)
Definition: World.cpp:483
bool Inscribe(QString) override
Returns true on success.
Definition: blocks.cpp:100
inner_actions ActInner() override
Definition: blocks.cpp:606
9
Definition: header.h:169
wearable Wearable() const override
Definition: blocks.cpp:101
void DoRareAction() override
Definition: blocks.cpp:244
14
Definition: Block.h:53
inner_actions
See Shred::PhysEventsRare() for details.
Definition: Active.h:36
void ReceiveSignal(QString) override
Receive text signal.
Definition: Active.cpp:156
11
Definition: header.h:171
int Y() const
Definition: Active.cpp:162
QString FullName() const override
Definition: blocks.cpp:560
static dirs MakeDirFromDamage(int damage_kind)
Definition: Block.cpp:83
bool Inscribe(QString) override
Returns true on success.
Definition: blocks.cpp:410
usage_types Use(Block *who) override
Definition: blocks.cpp:346
20
Definition: header.h:180
Block * GetBlock(int x, int y, int z) const
Definition: World.cpp:204
bool moved_in_this_turn
Definition: Animal.h:52
World * GetWorld() const
Definition: Active.cpp:140
bool Inscribe(QString) override
Returns true on success.
Definition: blocks.cpp:596
wearable Wearable() const override
Definition: blocks.cpp:623
Block * DropAfterDamage(bool *delete_block) override
Should return dropped block.
Definition: blocks.cpp:210
QString FullName() const override
Definition: blocks.cpp:622
void DamageAround() const
Definition: Active.cpp:118
QString FullName() const override
Definition: blocks.cpp:448
QString FullName() const override
Definition: blocks.cpp:42
usage_types Use(Block *who) override
Definition: blocks.cpp:192
Block * DropAfterDamage(bool *delete_block) override
Should return dropped block.
Definition: blocks.cpp:111
int LightRadius() const override
Definition: blocks.cpp:179
bool Catchable() const override
Definition: blocks.cpp:51
const WorldMap * GetMap() const
Definition: World.cpp:66
static QString DirString(dirs)
Definition: Block.cpp:75
int Sub() const
Definition: Block.h:144
void Damage(int dmg, int dmg_kind) override
Definition: blocks.cpp:202
usage_types Use(Block *who) override
Definition: blocks.cpp:319
void SaveAttributes(QDataStream &out) const override
Definition: blocks.cpp:530
wearable Wearable() const override
Definition: blocks.cpp:475
void DoRareAction() override
Definition: blocks.cpp:126
wearable
Definition: Block.h:28
12
Definition: header.h:172
subs
Substance block is made from.
Definition: header.h:157
void Damage(int dmg, int dmg_kind) override
Definition: blocks.cpp:363
bool locked
Definition: blocks.h:143
int DamageKind() const override
Definition: blocks.cpp:183
13
Definition: header.h:128
19
Definition: header.h:179
static Block * NewBlock(int kind, int sub)
Use this to receive a pointer to new not-normal block.
QString GetNote() const
Definition: Block.cpp:234
int DamageKind() const override
Definition: blocks.cpp:88
int ShouldAct() const override
Definition: blocks.cpp:98
int NutritionalValue(subs) const override
Definition: blocks.cpp:283
usage_types Use(Block *who) override
Definition: blocks.cpp:456
push_reaction PushResult(dirs) const override
Definition: blocks.cpp:103
static QString sharedMessage
Definition: blocks.h:228
long Longitude() const
Returns y (line) shred coordinate on world map.
Definition: Shred.cpp:59
Definition: Active.h:46
13
Definition: header.h:173
void ReceiveSignal(QString) override
Receive text signal.
Definition: blocks.cpp:589
char TypeOfShred(long longi, long lati) const
Definition: worldmap.cpp:63
25
Definition: header.h:185
usage_types
Definition: header.h:196
void ReceiveSignal(QString) override
Receive text signal.
Definition: blocks.cpp:189
virtual int Weight() const
Definition: Inventory.cpp:169
void DestroyAndReplace(int x, int y, int z)
Does not check target block durability.
Definition: World.cpp:525
usage_types Use(Block *who) override
Definition: blocks.cpp:564
inner_actions ActInner() override
Definition: blocks.cpp:194
dirs
Definition: header.h:85
void Push(int x, int y, int z, int push_direction)
Definition: Inventory.cpp:196
QString FullName() const override
Definition: blocks.cpp:270
int DamageLevel() const override
Definition: blocks.cpp:96
virtual Active * ActiveBlock()
Definition: Block.cpp:226
inner_actions ActInner() override
Definition: blocks.cpp:102
Provides block ability to contain other blocks inside.
Definition: Inventory.h:33
void Damage(int dmg, int dmg_kind) override
Definition: Active.cpp:142
0
Definition: header.h:160
usage_types Use(Block *user) override
Definition: blocks.cpp:639
bool InBounds(int x, int y) const
Definition: World.cpp:117
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.
Definition: World.cpp:550
Inventory * HasInventory() override
Definition: blocks.cpp:193
qint64 latiStart
Definition: blocks.h:194
Definition: header.h:96
void SaveAttributes(QDataStream &out) const override
Definition: blocks.cpp:218
int GetDurability() const
Definition: Block.cpp:232
int Weight() const override
Definition: blocks.cpp:190
16
Definition: header.h:131
void Break()
Set durability to null.
Definition: Block.cpp:230
QString FullName() const override
Definition: blocks.cpp:29
int Weight() const override
Definition: blocks.cpp:38
int Attractive(int sub) const override
Definition: blocks.cpp:234
11
Definition: Block.h:50
inner_actions ActInner() override
Definition: blocks.cpp:180
15
Definition: header.h:175
QString FullName() const override
Definition: blocks.cpp:476
virtual void ReceiveSignal(QString)
Receive text signal.
Definition: Block.cpp:211
inner_actions ActInner() override
Definition: blocks.cpp:376
Block without special physics and attributes.
Definition: Block.h:89
5
Definition: header.h:92
12
Definition: Block.h:51
8 (animal meat)
Definition: header.h:168
qint64 longiStart
coordinates map titled in. also ~center.
Definition: blocks.h:194
Telegraph(int sub, int id)
Definition: blocks.cpp:572
wearable Wearable() const override
Definition: blocks.cpp:637
bool IsSubAround(int sub) const
Returns true if there is at least 1 block of substance sub around.
Definition: Active.cpp:219
virtual void SaveAttributes(QDataStream &out) const
Definition: Inventory.cpp:65
17
Definition: header.h:177
14
Definition: header.h:174
virtual bool Inscribe(QString str)
Returns true on success.
Definition: Block.cpp:216
QString WorldName() const
Definition: World.cpp:65
Definition: blocks.h:170
int Weight() const override
Definition: blocks.cpp:52
usage_types UseOnShredMove(Block *who) override
Definition: blocks.cpp:477
int Enlightened(int x, int y, int z) const