Skip to content

Commit db65d76

Browse files
committed
w
1 parent f77d370 commit db65d76

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

source/archipelago/APInfo.hx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ typedef APSlotDataType = {
2424
songData: Map<String, SongDetailData>,
2525
?custom_weeks: Dynamic, // Custom weeks data from HScript processing
2626
?song_modifications: Dynamic, // Song additions/exclusions data
27-
?unoColorsUsed:{name:String, color:String} // Uno mod colors used in the slot
27+
?unoColorsUsed:Array<{name:String, color:String}> // Uno mod colors used in the slot
2828
}
2929

3030
abstract APSlotData(APSlotDataType) from APSlotDataType to APSlotDataType {
@@ -59,6 +59,7 @@ abstract APSlotData(APSlotDataType) from APSlotDataType to APSlotDataType {
5959
public var songData(get, never):Map<String, SongDetailData>;
6060
public var custom_weeks(get, never):Dynamic;
6161
public var song_modifications(get, never):Dynamic;
62+
public var unoColorsUsed(get, never):Array<{name:String, color:String}>;
6263

6364
private function get_deathLink():Bool return this.deathLink;
6465
private function get_fullSongCount():Int return this.fullSongCount;
@@ -73,6 +74,7 @@ abstract APSlotData(APSlotDataType) from APSlotDataType to APSlotDataType {
7374
private function get_songData():Map<String, SongDetailData> return this.songData;
7475
private function get_custom_weeks():Dynamic return this.custom_weeks;
7576
private function get_song_modifications():Dynamic return this.song_modifications;
77+
private function get_unoColorsUsed():Array<{name:String, color:String}> return this.unoColorsUsed;
7678

7779
public function get(key:String):Dynamic {
7880
return Reflect.field(this, key);

source/archipelago/APItem.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,10 @@ class APItem {
444444
popup('You got an UNO color!', "You got an UNO Color Filler!");
445445
// Get a random color from APInfo's SlotData that isn't already unlocked.
446446
var availableColors = APInfo.slotData.unoColorsUsed.filter(function(c) {
447-
return !unoColorsUnlocked.exists(function(uc) { return uc.name == c.name; });
447+
return !unoColorsUnlocked.arrayContainsObject(c);
448448
});
449449
if (availableColors.length > 0) {
450-
var color = FlxG.random.choice(availableColors);
450+
var color = FlxG.random.getObject(availableColors);
451451
unoColorsUnlocked.push(color);
452452
popup('You got the color ${color.name}!', "You got an UNO Color!");
453453
} else {

source/yutautil/CollectionUtils.hx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ class CollectionUtils
689689
}
690690
}
691691

692-
public static function isType(ob:Dynamic, type:Class<Dynamic>, ?NoSupers:Bool)
692+
public static inline function isType(ob:Dynamic, type:Class<Dynamic>, ?NoSupers:Bool)
693693
{
694694
var c = type;
695695
var o = ob;
@@ -699,6 +699,35 @@ class CollectionUtils
699699
return type == Type.getClass(ob) && Std.is(o, type);
700700
}
701701

702+
public static function compareObjects(obj1:Dynamic, obj2:Dynamic):Bool
703+
{
704+
if (obj1 == null || obj2 == null) return obj1 == obj2;
705+
var fields1 = Reflect.fields(obj1);
706+
var fields2 = Reflect.fields(obj2);
707+
if (fields1.length != fields2.length) return false;
708+
for (field in fields1)
709+
{
710+
if (!Reflect.hasField(obj2, field)) return false;
711+
var val1 = Reflect.field(obj1, field);
712+
var val2 = Reflect.field(obj2, field);
713+
if (Std.is(val1, Dynamic) && Std.is(val2, Dynamic))
714+
{
715+
if (!compareObjects(val1, val2)) return false;
716+
}
717+
else if (val1 != val2) return false;
718+
}
719+
return true;
720+
}
721+
722+
public static function arrayContainsObject<T>(arr:Array<T>, obj:T):Bool
723+
{
724+
for (item in arr)
725+
{
726+
if (compareObjects(item, obj)) return true;
727+
}
728+
return false;
729+
}
730+
702731

703732
public static inline function truthy(input:Dynamic):Bool
704733
{

0 commit comments

Comments
 (0)