Back to Index Page generated: Nov 12, 2024, 11:02:04 PM

Expansion Merchanter's Zeal

Content

Warnings

  1. http://wiki.alioth.net/index.php/Merchanter's%20Zeal -> 404 Not Found
  2. Information URL mismatch between OXP Manifest and Expansion Manager string length at character position 0

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Join the Merchanters' League for free, accurate, and succinct advice on buy- and sell-prices at every station in every system you visit. Advisories via the F4 Interface as well as witchpoint in-flight comms. MZ uses your trading history as its basis for buy-advice, and for sell-advice your own hold's manifest. It makes an ideal pairing with the lucrative More Moolah Market (MZ + MM = $$$) Join the Merchanters' League for free, accurate, and succinct advice on buy- and sell-prices at every station in every system you visit. Advisories via the F4 Interface as well as witchpoint in-flight comms. MZ uses your trading history as its basis for buy-advice, and for sell-advice your own hold's manifest. It makes an ideal pairing with the lucrative More Moolah Market (MZ + MM = $$$)
Identifier oolite.oxp.Reval.Merchanters_Zeal oolite.oxp.Reval.Merchanters_Zeal
Title Merchanter's Zeal Merchanter's Zeal
Category Mechanics Mechanics
Author Reval Reval
Version 1.1 1.1
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL n/a
Download URL https://wiki.alioth.net/img_auth.php/c/ca/Merchanters_Zeal.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1671375624

Documentation

Equipment

This expansion declares no equipment. This may be related to warnings.

Ships

This expansion declares no ships. This may be related to warnings.

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
Scripts/mz_script.js
"use strict";
this.name = "Merchanter's Zeal";
this.author = "Reval";
this.version = "1.1";
this.license = "CC-BY-NC-SA 4.0";
this.description = "Join the Merchanters' League for free, accurate, and succinct advice on buy- and sell-prices at every station in every system you visit. Advisories via the F4 Interface as well as witchpoint in-flight comms. MZ uses your trading history as its basis for buy-advice, and for sell-advice your own hold's manifest. It makes an ideal pairing with the lucrative More Moolah Market (MZ + MM = $$$)";


this.startUp = function() {
	// buy 'histories'
	this.$mzIndBuy = new Array();
	this.$mzAgrBuy = new Array();
	// balance necessary b/f WPSA kicks in
	this.$mzWPThresh = 2000;
}


this.startupComplete = function() {
	// load buy 'histories'
	var buy = missionVariables.mzAgrBuy; if (buy!=null) 
		this.$mzAgrBuy = JSON.parse(missionVariables.mzAgrBuy);
	buy = missionVariables.mzIndBuy; if (buy!=null)
		this.$mzIndBuy = JSON.parse(missionVariables.mzIndBuy);

	this.$mzSystem = System.systemNameForID(system.ID);
	var p = player.ship;
	var pc = player.commsMessage;
	// dock ship
	var sta = p.dockedStation;
	pc("The Merchanters' League welcomes you to "+this.$mzSystem+"!",7);
	pc("Please check our special advisories on your F4 Interface.",7);
	// prep ML Advisory interfaces
	this._mzPrepSales(sta);
	this._mzPrepBuy(sta);
}


this.playerWillSaveGame = function(message) {
	// save buy 'histories'
	missionVariables.mzAgrBuy = JSON.stringify(this.$mzAgrBuy);
	missionVariables.mzIndBuy = JSON.stringify(this.$mzIndBuy);
}



this.shipDockedWithStation = function(station) {
	this.$mzSystem = System.systemNameForID(system.ID);
	var p = player.ship;
	var pc = player.commsMessage;
	// dock ship
	pc("The Merchanters' League welcomes you to "+this.$mzSystem+"!",7);
	pc("Please check our special advisories on your F4 Interface.",7);
	// prep ML Advisory interfaces
	this._mzPrepSales(station);
	this._mzPrepBuy(station);
}


this.shipWillEnterWitchspace = function() {
	var ml = manifest.list;
	var pc = player.commsMessage;
	// note what was bought in last system
	var ind = (system.economy<4);
	if (ind) this.$mzIndBuy = ml; 
		else this.$mzAgrBuy = ml;
}


this.shipExitedWitchspace = function() {
	this.$mzSystem = System.systemNameForID(system.ID);
	// witchpoint sell-advisory via comms
	if (player.credits > this.$mzWPThresh)
		this._mzSellAdvisory();
}


// witchpoint sell-advisory via comms
this._mzSellAdvisory = function() {
	var s=system.stations, ml = manifest.list;
	var pc = player.commsMessage, ps = player.ship;
	var col = ps.messageGuiTextCommsColor;
	ps.messageGuiTextCommsColor = "orangeColor";
	// prices of ship's hold commodities, plus quantity
	var i = 0, c = 0;
	for (i=0; i<s.length; i++) {
		if (s[i].name!="Rock Hermit") { 
			for (c=0; c<ml.length; c++)
				pc(s[i].name + ": " + ml[c].displayName + " @ " + this._mzMPrice(s[i],ml[c].commodity) + " (" + this._mzMQuantity(s[i],ml[c].commodity) + ")",9);
		}
		pc(" ");
	}
	ps.messageGuiTextCommsColor = col;
}



/* helper functions */

// price of a good at a given station, in cr
this._mzMPrice = function(sta, good) {
	var price=0.0, mar=sta.market;
	price = mar[good].price/10;
	return price.toFixed(1);
}


// quantity of a good at a given station
this._mzMQuantity = function(sta, good) {
	var quant=0, mar=sta.market;
	quant = mar[good].quantity;
	return quant;
}



// F4 Interface Advisories


// create Sales Advisory on the F4 Interfaces screen
this._mzPrepSales = function(station) {
	station.setInterface("mzSales",{
	title: "ML Quick Sell Advisory",
	category: "$$ Merchanters' League",
	summary: "Sell-advice from the "+this.$mzSystem+" Merchanters' League.",
	callback: this._mzShowSales.bind(this)
	});	
}


// sell advice from the Merchanters' League
this._mzShowSales = function() {
	
	var parameters = new Object();
	
	parameters.title = "The "+this.$mzSystem+" Merchanters' League: Sell!";
	
	parameters.message = "";
	
	var s=system.stations, ml = manifest.list;
	// prices of ship's hold commodities, plus quantity
	var i = 0, c = 0;
	for (i=0; i<s.length; i++) {
		if (s[i].name!="Rock Hermit") { 
			for (c=0; c<ml.length; c++)
				parameters.message += s[i].name + ": " + ml[c].displayName + " @ " + this._mzMPrice(s[i],ml[c].commodity) + " (" + this._mzMQuantity(s[i],ml[c].commodity) + ") \n";
			parameters.message += " \n";
		}
	}

	parameters.choicesKey = "mzAcknowlege";
	
	mission.runScreen(parameters, callback);	

	function callback(choice) {
		if (choice === "1_YES")  player.commsMessage("Luck in the Markets!");
	}
}



// create Buy Advisory on the F4 Interfaces screen
this._mzPrepBuy = function(station) {
	station.setInterface("mzBuy",{
	title: "ML Quick Buy Advisory",
	category: "$$ Merchanters' League",
	summary: "Buy-advice from the "+this.$mzSystem+" Merchanters' League.",
	callback: this._mzShowBuy.bind(this)
	});	
}


// buy advice from the Merchanters' League
this._mzShowBuy = function() {
	
	var parameters = new Object();
	
	parameters.title = "The "+this.$mzSystem+" Merchanters' League: Buy!";
	
	parameters.message = "";
	
	var s=system.stations, ind = (system.economy<4);

	// use buy history from last agricultural or industrial system
	if (ind) var hist = this.$mzIndBuy; else var hist = this.$mzAgrBuy;
	// check that there _is_ a buying history
	if (hist.length==0) { 
		// there is no buying history
		parameters.message += "You have no buying-history yet, but here's our advice on two prime stock commodities...\n\n"; 
			var i = 0;
			if (ind) {
			for (i=0; i<s.length; i++) { 
				if (s[i].name!="Rock Hermit") { 
					parameters.message += s[i].name + ": Computers @ " + this._mzMPrice(s[i],"computers") + " (" + this._mzMQuantity(s[i],"computers") + ") \n";
					parameters.message += s[i].name + ": Luxuries @ " + this._mzMPrice(s[i],"luxuries") + " (" + this._mzMQuantity(s[i],"luxuries") + ") \n\n";
				}
			}
		} else {
			for (i=0; i<s.length; i++) { 
				if (s[i].name!="Rock Hermit") {
					parameters.message += s[i].name + ": Pelts & Furs @ " + this._mzMPrice(s[i],"furs") + " (" + this._mzMQuantity(s[i],"furs") + ") \n";
					parameters.message += s[i].name + ": Wines & Spirits @ " + this._mzMPrice(s[i],"liquor_wines") + " (" + this._mzMQuantity(s[i],"liquor_wines") + ") \n\n";
				}
			}
		}
		parameters.message += "\n";
	}
	// there _is_ a buying history
	else {

		// prices of ship's last hold commodities, plus quantity
		var i = 0, c = 0;
		for (i=0; i<s.length; i++) {
			if (s[i].name!="Rock Hermit") { 
				for (c=0; c<hist.length; c++)
					parameters.message += s[i].name + ": " + hist[c].displayName + " @ " + this._mzMPrice(s[i],hist[c].commodity) + " (" + this._mzMQuantity(s[i],hist[c].commodity) + ") \n";
				parameters.message += " \n";
			}
		}
	}
	
	parameters.choicesKey = "mzAcknowlege";
	
	mission.runScreen(parameters, callback);	

	function callback(choice) {
		if (choice === "1_YES")  player.commsMessage("Luck in the Markets!");
	}
}