Skip to content

Commit e72e447

Browse files
committed
eeee
1 parent 53dc421 commit e72e447

File tree

3 files changed

+176
-14
lines changed

3 files changed

+176
-14
lines changed

source/Main.hx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,20 @@ class CommandPrompt
930930
print("Error: multi-command requires at least one command.");
931931
}
932932

933+
case "testTrapLink":
934+
if (archipelago.APEntryState.inArchipelagoMode)
935+
if (args.length == 1)
936+
archipealgo.APGameState.instance?.doTrapLink({
937+
source: "apTest",
938+
trap_name: args[0],
939+
time: haxe.Timer.stamp()
940+
});
941+
942+
if (!archipelago.APEntryState.inArchipelagoMode)
943+
{
944+
print("Error: You can only use this command in Archipelago mode.");
945+
}
946+
933947
case "runCode":
934948
if (args.length > 0)
935949
{

source/archipelago/APYaml.hx

Lines changed: 109 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,110 @@ package archipelago;
33
import haxe.format.JsonParser;
44
import haxe.ds.StringMap;
55
import haxe.ds.Map;
6+
7+
abstract APOption(String) {
8+
public inline function new(v:String) {
9+
this = v;
10+
}
11+
12+
// Auto-conversion from various types
13+
@:from
14+
public static inline function fromString(value:String):APOption {
15+
return new APOption(value);
16+
}
17+
18+
@:from
19+
public static inline function fromBool(value:Bool):APOption {
20+
return new APOption(value ? "true" : "false");
21+
}
22+
23+
@:from
24+
public static inline function fromFloat(value:Float):APOption {
25+
return new APOption(Std.string(value));
26+
}
27+
28+
@:from
29+
public static inline function fromInt(value:Int):APOption {
30+
return new APOption(Std.string(value));
31+
}
32+
33+
@:from
34+
public static inline function fromArray(value:Array<String>):APOption {
35+
return new APOption("[" + value.join(", ") + "]");
36+
}
37+
38+
// Auto-conversion to various types
39+
@:to
40+
public inline function toString():String {
41+
return this;
42+
}
43+
44+
@:to
45+
public function toBool():Bool {
46+
return this == "true";
47+
}
48+
49+
@:to
50+
public function toFloat():Float {
51+
var parsed = Std.parseFloat(this);
52+
return Math.isNaN(parsed) ? 0.0 : parsed;
53+
}
54+
55+
@:to
56+
public function toInt():Int {
57+
return Std.int(toFloat());
58+
}
59+
60+
@:to
61+
public function toArray():Array<String> {
62+
if (this.startsWith("[") && this.endsWith("]")) {
63+
var content = this.substr(1, this.length - 2);
64+
return content.split(",").map(function(item) return item.trim());
65+
}
66+
return [this];
67+
}
68+
69+
// Smart parsing function that attempts to determine and convert to the appropriate type
70+
public function parseValue():Dynamic {
71+
// Check for array format
72+
if (this.startsWith("[") && this.endsWith("]")) {
73+
return toArray();
74+
}
75+
76+
// Check for boolean
77+
if (this == "true" || this == "false") {
78+
return toBool();
79+
}
80+
81+
// Check for numeric (float/int)
82+
var floatValue = Std.parseFloat(this);
83+
if (!Math.isNaN(floatValue)) {
84+
// Check if it's an integer
85+
if (floatValue == Std.int(floatValue)) {
86+
return toInt();
87+
}
88+
return toFloat();
89+
}
90+
91+
// Default to string
92+
return toString();
93+
}
94+
95+
// Check if the value represents a specific type
96+
public function isArray():Bool {
97+
return this.startsWith("[") && this.endsWith("]");
98+
}
99+
100+
public function isBool():Bool {
101+
return this == "true" || this == "false";
102+
}
103+
104+
public function isNumeric():Bool {
105+
return !Math.isNaN(Std.parseFloat(this));
106+
}
107+
}
108+
109+
6110
class APYaml {
7111
public var game:String;
8112
public var name:String;
@@ -44,22 +148,13 @@ class APYaml {
44148
var value = keyValue[1].trim();
45149

46150
if (key == "game")
47-
this.game = value;
151+
this.game = new APOption(value);
48152
else if (key == "name")
49-
this.name = value;
153+
this.name = new APOtion(value);
50154
else if (key == "description")
51-
this.description = value;
52-
53-
if (value.startsWith("[") && value.endsWith("]")) {
54-
value = value.substr(1, value.length - 2);
55-
sectionData.set(key, value.split(",").map(function(item) return item.trim()));
56-
} else if (value == "true" || value == "false") {
57-
sectionData.set(key, value == "true");
58-
} else if (cast(Std.parseFloat(value), Null<Float>) != null || Math.isNaN(Std.parseFloat(value))) {
59-
sectionData.set(key, Std.parseFloat(value));
60-
} else {
61-
sectionData.set(key, value);
62-
}
155+
this.description = new APOption(value);
156+
157+
sectionData.set(key, new APOption(value));
63158
}
64159
}
65160
}

source/objects/Strum.hx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package source.objects;
2+
3+
package objects;
4+
5+
abstract Strum(Dynamic) from Dynamic to Dynamic {
6+
public inline function new(value:Dynamic) {
7+
this = value;
8+
}
9+
10+
public inline function toStrumNote():StrumNote {
11+
return cast this;
12+
}
13+
14+
public inline function toString():String {
15+
return Std.string(this);
16+
}
17+
18+
@:from
19+
public static function fromStrumNote(note:StrumNote):Strum {
20+
return cast note;
21+
}
22+
23+
@:from
24+
public static function fromChartingStrumNote(note:objects.charting.ChartingStrumNote):Strum {
25+
return cast note;
26+
}
27+
28+
@:to
29+
public static function toStrumNote(strum:Strum):StrumNote {
30+
return cast strum;
31+
}
32+
33+
@:to
34+
public static function toChartingStrumNote(strum:Strum):objects.charting.ChartingStrumNote {
35+
return cast strum;
36+
}
37+
38+
public static function createStrumNote(x:Float, y:Float, leData:Int, ?playField:objects.playfields.PlayField):Strum {
39+
return cast new StrumNote(x, y, leData, playField);
40+
}
41+
42+
public static function createChartingStrumNote(x:Float, y:Float, leData:Int, player:Int):Strum {
43+
return cast new objects.charting.ChartingStrumNote(x, y, leData, player);
44+
}
45+
46+
public static function createStrum(x:Float, y:Float, leData:Int, player:Int):Strum {
47+
return cast new StrumNote(x, y, leData, player);
48+
}
49+
50+
public inline function toChartingStrumNote():objects.charting.ChartingStrumNote {
51+
return cast this;
52+
}
53+
}

0 commit comments

Comments
 (0)