Skip to content

Commit

Permalink
Crowd Control 2.0 preparations
Browse files Browse the repository at this point in the history
  • Loading branch information
Die4Ever committed May 26, 2023
1 parent f1af0ca commit f0677fa
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 77 deletions.
139 changes: 67 additions & 72 deletions RCTRandoCC.cs
Original file line number Diff line number Diff line change
@@ -1,91 +1,86 @@
using System;
using System.Collections.Generic;
using System;
using CrowdControl.Common;
using CrowdControl.Games.Packs;
using ConnectorType = CrowdControl.Common.ConnectorType;

public class RCTRando : SimpleTCPPack
{
public override string Host { get; } = "0.0.0.0";
public override string Host => "0.0.0.0";

public override ushort Port { get; } = 43385;
public override ushort Port => 43385;

public RCTRando(IPlayer player, Func<CrowdControlBlock, bool> responseHandler, Action<object> statusUpdateHandler) : base(player, responseHandler, statusUpdateHandler) { }
public override ISimpleTCPPack.MessageFormat MessageFormat => ISimpleTCPPack.MessageFormat.CrowdControlLegacy;

public override Game Game { get; } = new Game(141, "RollerCoaster Tycoon Randomizer", "RCTRando", "PC", ConnectorType.SimpleTCPConnector);
public RCTRando(UserRecord player, Func<CrowdControlBlock, bool> responseHandler, Action<object> statusUpdateHandler) : base(player, responseHandler, statusUpdateHandler) { }

public override List<Effect> Effects => new List<Effect> {
new Effect("Money", "money", ItemKind.Folder),
new Effect("Give $100", "give100", "money"),
new Effect("Give $1000", "give1000", "money"),
new Effect("Take $100", "take100", "money"),
new Effect("Take $1000", "take1000", "money"),
new Effect("Clear Loan", "zeroloan", "money"),
public override Game Game { get; } = new(152, "RollerCoaster Tycoon Randomizer", "RCTRando", "PC", ConnectorType.SimpleTCPConnector);

new Effect("Time Travel", "timetravel", ItemKind.Folder),
new Effect("Go Back One Month", "minusonemonth", "timetravel"),
new Effect("Go Back To March Year 1", "resetdate", "timetravel"),
new Effect("Force Scenario Win", "forcewin", "timetravel"),
public override EffectList Effects { get; } = new Effect[]
{
//new Effect("Money", "money", ItemKind.Folder),
new Effect("Give $100", "give100") { Category = "Money" },
new Effect("Give $1000", "give1000") { Category = "Money" },
new Effect("Take $100", "take100") { Category = "Money" },
new Effect("Take $1000", "take1000") { Category = "Money" },
new Effect("Clear Loan", "zeroloan") { Category = "Money" },

new Effect("Weather", "_weather", ItemKind.Folder),
new Effect("Make it Sunny", "forceweather0", "_weather"),
new Effect("Make it Partly Cloudy", "forceweather1", "_weather"),
new Effect("Make it Cloudy", "forceweather2", "_weather"),
new Effect("Make it Rain", "forceweather3", "_weather"),
new Effect("Make it Really Rain", "forceweather4", "_weather"),
new Effect("Make it Storm", "forceweather5", "_weather"),
new Effect("Make it Snow", "forceweather6", "_weather"),
new Effect("Make it Really Snow", "forceweather7", "_weather"),
new Effect("Make it Blizzard", "forceweather8", "_weather"),
new Effect("Random Weather", "forceweatherrandom", "_weather"),
new Effect("Freeze Weather", "freezeweather", "_weather"),
//new Effect("Time Travel", "timetravel", ItemKind.Folder),
new Effect("Go Back One Month", "minusonemonth") { Category = "Time Travel" },
new Effect("Go Back To March Year 1", "resetdate") { Category = "Time Travel" },
new Effect("Force Scenario Win", "forcewin") { Category = "Time Travel" },

new Effect("Rides", "rides", ItemKind.Folder),
//new Effect("Unlock Random Ride", "unlockride", "rides"),
//new Effect("Unlock Random Coaster", "unlockcoaster", "rides"),
//new Effect("Unlock Random Shop", "unlockshop", "rides"),
//new Effect("Fix a Ride", "fixride", "rides"),
new Effect("Fix All Rides", "fixallrides", "rides"),
//new Effect("Break a Ride", "breakRide", "rides"),
new Effect("Fast Chain Lifts", "fastchainlift", "rides"),
new Effect("Slow Chain Lifts", "slowchainlift", "rides"),

new Effect("Re-Randomize Rides", "rerollrides", "rides"),
//new Effect("Weather", "_weather", ItemKind.Folder),
new Effect("Make it Sunny", "forceweather0") { Category = "Weather" },
new Effect("Make it Partly Cloudy", "forceweather1") { Category = "Weather" },
new Effect("Make it Cloudy", "forceweather2") { Category = "Weather" },
new Effect("Make it Rain", "forceweather3") { Category = "Weather" },
new Effect("Make it Really Rain", "forceweather4") { Category = "Weather" },
new Effect("Make it Storm", "forceweather5") { Category = "Weather" },
new Effect("Make it Snow", "forceweather6") { Category = "Weather" },
new Effect("Make it Really Snow", "forceweather7") { Category = "Weather" },
new Effect("Make it Blizzard", "forceweather8") { Category = "Weather" },
new Effect("Random Weather", "forceweatherrandom") { Category = "Weather" },
new Effect("Freeze Weather", "freezeweather") { Category = "Weather" },

new Effect("Peeps", "peeps", ItemKind.Folder),
new Effect("Name Peep After Me", "peepnameafterdonator", "peeps"),
new Effect("Recolor Peeps", "peeprecolor", "peeps"),
new Effect("Feed Peeps", "peepfeed", "peeps"),
new Effect("Make Peeps Hungry", "peepunfeed", "peeps"),
new Effect("Quench Peeps", "peepdrink", "peeps"),
new Effect("Make Peeps Thirsty", "peepundrink", "peeps"),
new Effect("Fill Peeps Bladders", "peepfillbladder", "peeps"),
new Effect("Empty Peeps' Bladders", "peepemptybladder", "peeps"),
new Effect("Give Peeps Money", "peepgivemoney", "peeps"),
new Effect("Take Peeps' Money", "peeptakemoney", "peeps"),
new Effect("Give Peeps Balloons", "peepgiveballoon", "peeps"),
//new Effect("Release Peeps' Balloons", "peepreleaseballoon", "peeps"),
//new Effect("Rides", "rides", ItemKind.Folder),
//new Effect("Unlock Random Ride", "unlockride") { Category = "Rides" },
//new Effect("Unlock Random Coaster", "unlockcoaster") { Category = "Rides" },
//new Effect("Unlock Random Shop", "unlockshop") { Category = "Rides" },
//new Effect("Fix a Ride", "fixride") { Category = "Rides" },
new Effect("Fix All Rides", "fixallrides") { Category = "Rides" },
//new Effect("Break a Ride", "breakRide") { Category = "Rides" },
new Effect("Fast Chain Lifts", "fastchainlift") { Category = "Rides" },
new Effect("Slow Chain Lifts", "slowchainlift") { Category = "Rides" },
new Effect("Re-Randomize Rides", "rerollrides") { Category = "Rides" },

new Effect("Scenery", "scenery", ItemKind.Folder),
new Effect("Clean Paths", "cleanpaths", "scenery"),
new Effect("Mow Grass", "mowgrass", "scenery"),
new Effect("Unmow Grass", "unmowgrass", "scenery"),
new Effect("Water Plants", "waterplants", "scenery"),
new Effect("Burn Plants", "burnplants", "scenery"),
new Effect("Smash Scenery", "smashscenery", "scenery"),
new Effect("Fix Scenery", "fixscenery", "scenery"),
//new Effect("Peeps", "peeps", ItemKind.Folder),
new Effect("Name Peep After Me", "peepnameafterdonator") { Category = "Peeps" },
new Effect("Recolor Peeps", "peeprecolor") { Category = "Peeps" },
new Effect("Feed Peeps", "peepfeed") { Category = "Peeps" },
new Effect("Make Peeps Hungry", "peepunfeed") { Category = "Peeps" },
new Effect("Quench Peeps", "peepdrink") { Category = "Peeps" },
new Effect("Make Peeps Thirsty", "peepundrink") { Category = "Peeps" },
new Effect("Fill Peeps Bladders", "peepfillbladder") { Category = "Peeps" },
new Effect("Empty Peeps' Bladders", "peepemptybladder") { Category = "Peeps" },
new Effect("Give Peeps Money", "peepgivemoney") { Category = "Peeps" },
new Effect("Take Peeps' Money", "peeptakemoney") { Category = "Peeps" },
new Effect("Give Peeps Balloons", "peepgiveballoon") { Category = "Peeps" },
//new Effect("Release Peeps' Balloons", "peepreleaseballoon") { Category = "Peeps" },

new Effect("Spawn Ducks", "spawnducks"),
new Effect("Clear Ducks", "clearducks"),
new Effect("Open Random Windows", "openrandomwindows"),
new Effect("Close All Windows", "closeallwindows"),
//new Effect("Scenery", "scenery", ItemKind.Folder),
new Effect("Clean Paths", "cleanpaths") { Category = "Scenery" },
new Effect("Mow Grass", "mowgrass") { Category = "Scenery" },
new Effect("Unmow Grass", "unmowgrass") { Category = "Scenery" },
new Effect("Water Plants", "waterplants") { Category = "Scenery" },
new Effect("Burn Plants", "burnplants") { Category = "Scenery" },
new Effect("Smash Scenery", "smashscenery") { Category = "Scenery" },
new Effect("Fix Scenery", "fixscenery") { Category = "Scenery" },

new Effect("Extend Scenario Goal", "extendscenario")
};
new Effect("Spawn Ducks", "spawnducks"),
new Effect("Clear Ducks", "clearducks"),
new Effect("Open Random Windows", "openrandomwindows"),
new Effect("Close All Windows", "closeallwindows"),

//Slider ranges need to be defined
/*public override List<ItemType> ItemTypes => new List<ItemType>(new[]
{
new ItemType("Money", "money1000", ItemType.Subtype.Slider, "{\"min\":1,\"max\":1000}")
});*/
new Effect("Extend Scenario Goal", "extendscenario")
};
}
4 changes: 2 additions & 2 deletions src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ function DeepCopy(o) {

// game state can't be modified outside of synchronized functions, and tick is one of them
function runNextTick(func) {
let sub = context.subscribe('interval.tick', function(args) {
//use executeAction instead?
context.executeAction('RCTRandoExec', {}, function(a) {
try {
func();
} catch(e) {
printException('error in runNextTick', e);
}
sub.dispose();
});
}

Expand Down
6 changes: 3 additions & 3 deletions src/modules/moduleBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract class ModuleBase {

// settings and savestate management would be good here, need constructor

SubscribeEvent(event: HookType, callback: Function) {
protected SubscribeEvent(event: HookType, callback: Function) {
let s = context.subscribe(event, callback);
this.subscriptions.push(s);
}
Expand All @@ -42,15 +42,15 @@ abstract class ModuleBase {
this.subscriptions = [];
}

AddChange(key, name, from, to, factor=null) {
protected AddChange(key, name, from, to, factor=null) {
var obj = {name: name, from: from, to: to, factor: factor};
info(this.constructor.name, 'AddChange', key, JSON.stringify(obj));

this.settings.changes[key] = obj;
this.SaveSettings();
}

RandomizeField(obj:Object, name:string, difficulty:number) {
protected RandomizeField(obj:Object, name:string, difficulty:number) {
if(!obj[name]) return;

const old = obj[name];
Expand Down

0 comments on commit f0677fa

Please sign in to comment.