~ubuntu-branches/ubuntu/maverick/lordsawar/maverick

« back to all changes in this revision

Viewing changes to src/reward.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2010-04-10 09:29:33 UTC
  • mfrom: (1.1.9 upstream) (5.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100410092933-23uq4dxig30kmtcw
Tags: 0.1.8-1
* New upstream release.
* Add misc:Depends for -data package.
* Bump Standards Version to 3.8.4. (No changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
          //! A portion of the hidden map to expose to the rewarded player.
68
68
          MAP = 5
69
69
        };
70
 
        static std::string rewardTypeToString(const Reward::Type type);
71
 
        static Reward::Type rewardTypeFromString(const std::string str);
72
70
 
73
71
        //! Default constructor.
74
72
        /**
106
104
         */
107
105
        Reward (const Reward& orig);
108
106
 
109
 
        //! deep copy a reward into another one
110
 
        static Reward* copy(const Reward* r);
111
 
 
112
107
        //! Destructor.
113
108
        virtual ~Reward();
114
109
 
 
110
 
 
111
        // Get Methods
 
112
 
115
113
        //! Get the type of the reward.
116
114
        Type getType() const { return d_type; }
117
115
 
 
116
        //! Returns the name of the reward.
 
117
        std::string getName() const {return d_name;}
 
118
 
 
119
 
 
120
        // Set Methods
 
121
 
118
122
        //! Sets the name of the reward.
119
123
        void setName(std::string name) {d_name = name;}
120
124
 
121
 
        //! Returns the name of the reward.
122
 
        std::string getName() const {return d_name;}
 
125
 
 
126
        // Methods that operate on the class data but do not modify the class.
123
127
 
124
128
        //! Generates a description of this reward.
125
129
        /**
126
130
         * This method inspects the underlying reward and generates an
127
131
         * appropriate description.
128
132
         */
129
 
        std::string getDescription();
 
133
        std::string getDescription() const;
130
134
 
131
135
        //! Saves the data elements common to all rewards.
132
136
        /**
137
141
         * @param helper  The opened saved-game file to save the Reward object
138
142
         *                to.
139
143
         */
140
 
        virtual bool save(XML_Helper* helper)= 0;
 
144
        virtual bool save(XML_Helper* helper) const = 0;
 
145
 
 
146
 
 
147
        // Static Methods
141
148
 
142
149
        //! Assist in the loading of Rewards of all kinds.
143
150
        /**
149
156
         */
150
157
        static Reward* handle_load(XML_Helper* helper);
151
158
 
 
159
        //! Convert a Reward::Type enumerated value to a string.
 
160
        static std::string rewardTypeToString(const Reward::Type type);
 
161
 
 
162
        //! Convert a Reward::Type string to an enumerated value.
 
163
        static Reward::Type rewardTypeFromString(const std::string str);
 
164
 
 
165
        //! deep copy a reward into another one
 
166
        static Reward* copy(const Reward* r);
 
167
 
152
168
    protected:
153
169
 
 
170
        // DATA
 
171
 
154
172
        //! Type of the reward.
155
173
        Type d_type;
156
174
 
171
189
         * @param gold  The number of gold pieces to award the Player.
172
190
         */
173
191
        Reward_Gold(guint32 gold);
 
192
 
174
193
        //! Loading constructor.
175
194
        Reward_Gold(XML_Helper *helper);
 
195
 
176
196
        //! Copy constructor.
177
197
        Reward_Gold(const Reward_Gold& orig);
 
198
 
178
199
        //! Destructor.
179
200
        ~Reward_Gold();
180
201
 
 
202
        // Get Methods
 
203
 
 
204
        //! Return the number of gold pieces associated with this reward.
 
205
        guint32 getGold() const {return d_gold;}
 
206
 
 
207
 
 
208
        // Methods that operate on the class data but do not modify the class.
 
209
 
 
210
        //! Save the gold reward to the opened saved-game file.
 
211
        bool save(XML_Helper* helper) const;
 
212
 
 
213
 
 
214
        // Static Methods
 
215
 
181
216
        //! Return a random number of gold pieces.
182
217
        /**
183
218
         * This method provides a random number of gold pieces suitable for a
184
219
         * reward in the game.
185
220
         */
186
221
        static guint32 getRandomGoldPieces();
187
 
 
188
 
        //! Save the gold reward to the opened saved-game file.
189
 
        bool save(XML_Helper* helper);
190
 
 
191
 
        //! Return the number of gold pieces associated with this reward.
192
 
        guint32 getGold() const {return d_gold;}
193
 
 
194
222
    private:
 
223
 
 
224
        // DATA
 
225
 
195
226
        //! The number of gold pieces to award the player.
196
227
        guint32 d_gold;
197
228
};
211
242
         */
212
243
        Reward_Allies(const ArmyProto *army, guint32 count);
213
244
 
214
 
        //! Secondary constructor.  Make a new reward of allies.
 
245
        //! Alternative constructor.  Make a new reward of allies.
215
246
        /**
216
247
         * @param army_type  The Id of the Army prototype to create allies from.
217
248
         * @param army_set   The Id of the Armyset that the type belongs to.
228
259
        //! Destructor.
229
260
        ~Reward_Allies();
230
261
 
231
 
        //! Save the allies reward to the opened saved-game file.
232
 
        bool save(XML_Helper* helper);
 
262
        // Get Methods
233
263
 
234
264
        //! Return the army prototype of the allies associated with this reward.
235
265
        const ArmyProto * getArmy() const {return d_army;}
237
267
        //! Return the number allies that this reward will create.
238
268
        guint32 getNoOfAllies() const {return d_count;}
239
269
 
 
270
 
 
271
        // Methods that operate on the class data and do not modify the class.
 
272
 
 
273
        //! Save the allies reward to the opened saved-game file.
 
274
        bool save(XML_Helper* helper) const;
 
275
 
 
276
 
 
277
        // Static Methods
 
278
 
240
279
        //! A static method that returns a random awardable Army prototype.
241
280
        static const ArmyProto* randomArmyAlly();
242
281
 
279
318
        static bool addAllies(Player *p, Location *l, const Army *army, guint32 alliesCount);
280
319
 
281
320
    private:
 
321
        // DATA
 
322
 
282
323
        //! The Army prototype that represents the allies to give the Player.
283
324
        const ArmyProto *d_army;
 
325
 
284
326
        //! The army type of the given prototype.
285
327
        guint32 d_army_type;
 
328
 
286
329
        //! The army set of the given prototype.
287
330
        guint32 d_army_set;
 
331
 
288
332
        //! The number of allies to give the Player.
289
333
        guint32 d_count;
290
334
};
323
367
        //! Destructor.
324
368
        ~Reward_Item();
325
369
 
 
370
 
 
371
        // Get Methods
 
372
 
 
373
        //! Get the Item object associated with this reward.
 
374
        Item *getItem() const {return d_item;}
 
375
 
 
376
 
 
377
        // Methods that operate on the class data but do not modify the class.
 
378
 
 
379
        //! Save the reward item to a file.
 
380
        /**
 
381
         * @param helper  The opened saved-game file to save the reward item to.
 
382
         */
 
383
        bool save(XML_Helper* helper) const;
 
384
 
 
385
 
 
386
        // Static Methods
 
387
 
326
388
        //! Return a random Item object.
327
389
        /**
328
390
         * @note This method does not return an Reward_Item object.
333
395
         */
334
396
        static Item *getRandomItem();
335
397
 
336
 
        //! Save the reward item to a file.
337
 
        /**
338
 
         * @param helper  The opened saved-game file to save the reward item to.
339
 
         */
340
 
        bool save(XML_Helper* helper);
341
 
 
342
 
        //! Get the Item object associated with this reward.
343
 
        Item *getItem() const {return d_item;}
344
 
 
345
398
    private:
346
399
        //! Callback to load the Item object in the Reward_Item object.
347
400
        bool loadItem(std::string tag, XML_Helper* helper);
348
401
 
 
402
        // DATA
 
403
 
349
404
        //! A pointer to the Item object associated with this Reward_Item.
350
405
        Item *d_item;
351
406
};
388
443
        //! Destructor.
389
444
        ~Reward_Ruin();
390
445
 
 
446
        // Get Methods
 
447
 
 
448
        //! Return the Ruin object associated with this Reward_Ruin.
 
449
        Ruin* getRuin() const 
 
450
          {return Ruinlist::getInstance()->getObjectAt(d_ruin_pos);}
 
451
 
 
452
        // Methods that operate on the class data but do not modify the class.
 
453
 
 
454
        //! Save the reward ruin to an opened saved-game file.
 
455
        /**
 
456
         * @param helper  The opened saved-game file to write the ruin reward 
 
457
         *                to.
 
458
         */
 
459
        bool save(XML_Helper* helper) const;
 
460
 
 
461
 
 
462
        // Static Methods
 
463
 
391
464
        //! Go get a random hidden ruin to give to the Player.
392
465
        /**
393
466
         * Scan all of the Ruin objects in the game and find one that is
403
476
         */
404
477
        static Ruin *getRandomHiddenRuin();
405
478
 
406
 
        //! Save the reward ruin to an opened saved-game file.
407
 
        /**
408
 
         * @param helper  The opened saved-game file to write the ruin reward 
409
 
         *                to.
410
 
         */
411
 
        bool save(XML_Helper* helper);
412
 
 
413
 
        //! Return the Ruin object associated with this Reward_Ruin.
414
 
        Ruin* getRuin() const 
415
 
          {return Ruinlist::getInstance()->getObjectAt(d_ruin_pos);}
416
 
 
417
479
    private:
 
480
 
 
481
        // DATA
 
482
 
418
483
        //! The position of the Ruin object associated with this reward.
419
 
        /**
420
 
         * The ruin is saved as a position for a good reason, but I don't know
421
 
         * what that reason is.  Perhaps the Ruinlist was loaded after the
422
 
         * Rewardlist at one time (but isn't any longer).
423
 
         * Maybe it is because a Ruin can reference a Reward_Ruin which can
424
 
         * reference a (hidden) Ruin.
425
 
         */
426
 
        //FIXME: verify that the ruin's position has to be used here.
427
484
        Vector<int> d_ruin_pos;
428
485
};
429
486
 
471
528
        ~Reward_Map();
472
529
 
473
530
 
474
 
        bool loadMap(std::string tag, XML_Helper* helper);
475
 
 
476
 
        //! Save the reward map to an opened saved-game file.
477
 
        /**
478
 
         * @param helper  The opened saved-game file to write the ruin map to.
479
 
         */
480
 
        bool save(XML_Helper* helper);
 
531
        // Set Methods
 
532
 
 
533
        //! Set the name of the map in this reward.
 
534
        void setMapName(std::string name) {d_sightmap->setName(name);};
 
535
 
 
536
 
 
537
        // Get Methods
 
538
 
 
539
        //! Return the top left corner of the map in this reward.
 
540
        Vector<int> getLocation() const {return d_sightmap->pos;};
 
541
 
 
542
        //! Return the map in this reward.
 
543
        SightMap * getSightMap() {return d_sightmap;};
 
544
 
 
545
        //! Return the name of the map in this reward.
 
546
        std::string getMapName() const {return d_sightmap->getName();};
481
547
 
482
548
        //! Get the height of the revealed portion of the game map.
483
549
        guint32 getHeight() const {return d_sightmap->h;}
485
551
        //! Get the width of the revealed portion of the game map.
486
552
        guint32 getWidth() const {return d_sightmap->w;}
487
553
 
 
554
 
 
555
        // Methods that operate on the class data and modify the class.
 
556
 
 
557
        bool loadMap(std::string tag, XML_Helper* helper);
 
558
 
 
559
 
 
560
        // Methods that operate on the class data and do not modify the class.
 
561
 
 
562
        //! Save the reward map to an opened saved-game file.
 
563
        /**
 
564
         * @param helper  The opened saved-game file to write the ruin map to.
 
565
         */
 
566
        bool save(XML_Helper* helper) const;
 
567
 
 
568
 
 
569
        // Static Methods
 
570
 
488
571
        //! Return a description of a random map.
489
572
        /**
490
573
         * @note This will produce random maps that overlap each other.
499
582
         */
500
583
        static void getRandomMap(int *x, int *y, int *width, int *height);
501
584
 
502
 
        Vector<int> getLocation() {return d_sightmap->pos;};
503
 
 
504
 
        SightMap * getSightMap() {return d_sightmap;};
505
 
 
506
 
        void setMapName(std::string name) {d_sightmap->setName(name);};
507
 
        std::string getMapName() const {return d_sightmap->getName();};
508
585
 
509
586
    private:
 
587
 
 
588
        // DATA
510
589
        SightMap *d_sightmap;
511
590
};
512
591