-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclue_helper.nut
66 lines (58 loc) · 1.91 KB
/
clue_helper.nut
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
//////////////////////////////////////////////////////////////////////
// //
// CluelessPlus - an noai-AI //
// //
//////////////////////////////////////////////////////////////////////
//
// Author: Zuu (Leif Linse), user Zuu @ tt-forums.net
// Purpose: To play around with the noai framework.
// - Not to make the next big thing.
// Copyright: Leif Linse - 2008-2011
// License: GNU GPL - version 2
// This class contain helper functions that has not been merged into
// the common Helper class for both CluelessPlus and PAXLink
class ClueHelper {
static function StepFunction(t);
static function TileLocationString(tile);
static function IsTownInConnectionList(connection_list, check_town, cargo_id = -1); // cargo_id = -1 -> any cargo is enough
static function IsIndustryInConnectionList(connection_list, check_industry, cargo_id = -1);
}
function ClueHelper::StepFunction(t)
{
if(t>=0)
return 1;
return 0;
}
function ClueHelper::TileLocationString(tile)
{
return "(" + AIMap.GetTileX(tile) + ", " + AIMap.GetTileY(tile) + ")";
}
function ClueHelper::IsTownInConnectionList(connection_list, check_town, cargo_id = -1)
{
foreach(val in connection_list)
{
foreach(town in val.town)
{
if(town == check_town && (cargo_id == -1 || val.cargo_type == cargo_id))
{
return true;
}
}
}
return false;
}
function ClueHelper::IsIndustryInConnectionList(connection_list, check_industry, cargo_id = -1)
{
foreach(val in connection_list)
{
foreach(industry in val.industry)
{
if(industry == check_industry && (cargo_id == -1 || val.cargo_type == cargo_id))
{
Log.Info(AIIndustry.GetName(check_industry) + " is not used by any connection for cargo_id == " + cargo_id, Log.LVL_DEBUG);
return true;
}
}
}
return false;
}