annotate api/Requirements/UnitRequiresAtLeastRequirement.cs @ 230:73da8d13ce69

Re #223: Use translations within the API * Fix build error caused by changing private field types no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Thu, 24 Dec 2009 10:33:20 +0000
parents 6083010a005c
children d1c90159547a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104
2f3cafb69799 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 82
diff changeset
1 // This file (UnitRequiresAtLeastRequirement.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2008, 2009 IBBoard.
15
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
2 //
104
2f3cafb69799 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 82
diff changeset
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
15
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
4
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
5 using System;
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System.Collections.Generic;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using System.Text;
229
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
8 using IBBoard.Lang;
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using IBBoard.WarFoundry.API;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
10 using IBBoard.WarFoundry.API.Objects;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
11
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
12 namespace IBBoard.WarFoundry.API.Requirements
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
13 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
14 /// <summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
15 /// Summary description for UnitRequiresRequirement.
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
16 /// </summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
17 public class UnitRequiresAtLeastRequirement : UnitRequirement
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
18 {
229
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
19 private UnitRequirementItem[] requiredTypes;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
20 private String unitList;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
21
229
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
22 public UnitRequiresAtLeastRequirement(UnitType type, UnitType requiredUnitType) : this(type, new UnitRequirementItem[]{new UnitRequirementItem(requiredUnitType)})
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
23 {
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25
229
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
26 public UnitRequiresAtLeastRequirement(UnitType type, UnitRequirementItem[] requiredUnitTypes) : base(type)
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
27 {
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 requiredTypes = requiredUnitTypes;
229
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
29 bool first = true;
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
30
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
31 foreach (UnitRequirementItem req in requiredTypes)
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
32 {
229
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
33 string reqString = Translation.GetTranslation("requirementUnitTypeAtLeastSingle", "{1} {0}", req.UnitType.Name, req.Amount);
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
34
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
35 if (first)
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
36 {
229
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
37 first = false;
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
38 unitList = reqString;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
39 }
229
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
40 else
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
41 {
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
42 unitList = Translation.GetTranslation("requirementUnitTypeAtLeastJoiner", "{0}, {1}", unitList, reqString);
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
43 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
44 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
45 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
46
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
47 public override string Description
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
48 {
229
6083010a005c Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 104
diff changeset
49 get { return Translation.GetTranslation("requirementUnitTypeAtLeast", "the army must include at least the following units to include a unit of type {0}: {1}", unitType.Name, unitList); }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
50 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
51
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
52 protected override AbstractFailedRequirement CanRemoveFromArmy(Army army, UnitType type)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
53 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
54 return null;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
55 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
56
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
57 protected override AbstractFailedRequirement CanAddToArmy(Army army, UnitType type)
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 FailedRequirement failure = null;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 int count = requiredTypes.Length;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61
230
73da8d13ce69 Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 229
diff changeset
62 foreach (UnitRequirementItem req in requiredTypes)
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
63 {
230
73da8d13ce69 Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents: 229
diff changeset
64 if (army.GetUnitTypeCount(req.UnitType) < req.Amount)
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
65 {
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 failure = new FailedRequirement(this);
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
67 break;
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
71 return failure;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
72 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
73 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
74 }