From e33e19d0587146859d48a134ec9fd94e7b7ba5cd Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Thu, 8 Dec 2011 14:53:40 +0000 Subject: Initial upload --- Stars45/CombatAssignment.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Stars45/CombatAssignment.cpp (limited to 'Stars45/CombatAssignment.cpp') diff --git a/Stars45/CombatAssignment.cpp b/Stars45/CombatAssignment.cpp new file mode 100644 index 0000000..b4687cd --- /dev/null +++ b/Stars45/CombatAssignment.cpp @@ -0,0 +1,68 @@ +/* Project Starshatter 4.5 + Destroyer Studios LLC + Copyright © 1997-2004. All Rights Reserved. + + SUBSYSTEM: Stars.exe + FILE: CombatAssignment.cpp + AUTHOR: John DiCamillo + + + OVERVIEW + ======== + High level assignment of one group to damage another +*/ + +#include "MemDebug.h" +#include "CombatAssignment.h" +#include "CombatGroup.h" +#include "Mission.h" + +// +--------------------------------------------------------------------+ + +CombatAssignment::CombatAssignment(int t, CombatGroup* obj, CombatGroup* rsc) + : type(t), objective(obj), resource(rsc) +{ +} + +// +--------------------------------------------------------------------+ + +CombatAssignment::~CombatAssignment() +{ +} + +// +--------------------------------------------------------------------+ +// This is used to sort assignments into a priority list. +// Higher priorities should come first in the list, so the +// sense of the operator is "backwards" from the usual. + +int +CombatAssignment::operator < (const CombatAssignment& a) const +{ + if (!objective) + return 0; + + if (!a.objective) + return 1; + + return objective->GetPlanValue() > a.objective->GetPlanValue(); +} + +// +--------------------------------------------------------------------+ + +const char* +CombatAssignment::GetDescription() const +{ + static char desc[256]; + + if (!resource) + sprintf(desc, "%s %s", + (const char*) Mission::RoleName(type), + (const char*) objective->Name()); + else + sprintf(desc, "%s %s %s", + (const char*) resource->Name(), + (const char*) Mission::RoleName(type), + (const char*) objective->Name()); + + return desc; +} -- cgit v1.1