-
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathWinterOrders.cpp
More file actions
71 lines (60 loc) · 1.82 KB
/
Copy pathWinterOrders.cpp
File metadata and controls
71 lines (60 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//==============================================================================
//
// WinterOrders.cpp
//
// Diplomacy AI Client - Part of the DAIDE project (www.daide.org.uk).
//
// (C) David Norman 2002 david@ellought.demon.co.uk
// (C) Greg Utas 2019-2025 greg@pentennea.com
//
// This software may be reused for non-commercial purposes without charge,
// and without notifying the authors. Use of any part of this software for
// commercial purposes without permission from the authors is prohibited.
//
#include "WinterOrders.h"
#include <iterator>
#include <ostream>
#include <utility>
#include "Location.h"
#include "SysTypes.h"
#include "Token.h"
using std::ostream;
//------------------------------------------------------------------------------
namespace Diplomacy
{
WinterOrders::WinterOrders() :
number_of_orders_required(0),
number_of_waives(0),
is_building(false)
{
}
//------------------------------------------------------------------------------
size_t WinterOrders::get_number_of_results() const
{
return (adjustments.size() + number_of_waives);
}
//------------------------------------------------------------------------------
ostream& operator<<(ostream& stream, const WinterOrders& orders)
{
if(orders.adjustments.size() + orders.number_of_waives == 0)
{
stream << "none";
return stream;
}
if(!orders.adjustments.empty())
{
stream << (orders.is_building ? "Build" : "Remove");
}
for(auto a = orders.adjustments.begin(); a != orders.adjustments.cend(); ++a)
{
stream << SPACE << a->first.coast << SPACE << a->first;
if(std::next(a) != orders.adjustments.cend()) stream << ',';
}
if(orders.number_of_waives > 0)
{
if(!orders.adjustments.empty()) stream << ", ";
stream << "Waives " << orders.number_of_waives;
}
return stream;
}
}