Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added all shops in Lumbridge, Falador, Edgeville, and Al-Kharid #407

Closed
wants to merge 2 commits into from
Closed

Added all shops in Lumbridge, Falador, Edgeville, and Al-Kharid #407

wants to merge 2 commits into from

Conversation

Arham4
Copy link
Contributor

@Arham4 Arham4 commented Jul 26, 2018

Should hopefully resolve issue #362

@tlf30
Copy link
Contributor

tlf30 commented Jul 26, 2018

Can you please compare your shops to my existing plugin that adds all shops?
https://github.com/tlf30/apollo-plugins

@Arham4
Copy link
Contributor Author

Arham4 commented Jul 26, 2018

Some item amounts are a little off (mine are from OSRS, I assume yours are from RS3?). Other than that, items seem to be just right.

Example, yours:

shop("Louie's Armoured Legs Bazaar") {
    operated by "Louie Legs"(542)

    sell(10) of {
        - "Bronze platelegs"(1075)
        - "Iron platelegs"(1067)
        - "Steel platelegs"(1069)
        - "Black platelegs"(1077)
        - "Mithril platelegs"(1071)
        - "Adamant platelegs"(1073)
    }
}

Mine:

shop("Louie's Armoured Legs Bazaar") {
    operated by "Louie Legs"

    sell(5) of "Bronze platelegs"
    sell(3) of "Iron platelegs"
    sell(2) of "Steel platelegs"
    sell(1) of "Black platelegs"
    sell(1) of "Mithril platelegs"
    sell(1) of "Adamant platelegs"
}

RS3 wiki: http://runescape.wikia.com/wiki/Louie%27s_Armoured_Legs_Bazaar
OSRS wiki: http://oldschoolrunescape.wikia.com/wiki/Louie%27s_Armoured_Legs_Bazaar

@tlf30
Copy link
Contributor

tlf30 commented Jul 26, 2018

Mine is based from a compilation of other rs377 ports. Should not have any rs3, all rs2. I was just wondering, I don't know if mine is correct, just that it is based on what other rs2 377 servers have uses in the past

@Arham4
Copy link
Contributor Author

Arham4 commented Jul 27, 2018

Oh I see. Perhaps OSRS is modified?

@tlf30
Copy link
Contributor

tlf30 commented Jul 27, 2018

Yes, OSRS has had changes to its shops inventories. But I am not sure what those changes are. Honestly, I don't know if there will ever be a way to get the exact shop info without being given the actual code. As far as I am concerned, either of our lists is fine. Yours is more organized than mine, which is why I kept mine in my repo instead of opening a pr.

@Arham4
Copy link
Contributor Author

Arham4 commented Jul 28, 2018

Yours is really helpful though. If I have permission, in my free time I could perhaps organize your disordered shops plugin?

@Major-
Copy link
Member

Major- commented Jul 28, 2018

Really good work, thanks, this is a perfect example of how I intended the shops plugin to be used. I think generally if there's a discrepancy we should default to the stock in OSRS, unless there's clear evidence (e.g. a video of real RS from 2006 showing the shop inventory). Lots of other servers will have slapped stuff together and probably isn't all that reliable

operated by "Louie Legs"

/*
FIXME when this is a category("platelegs"), the s at the end of 'platelegs' is omitted for some reason.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solution to this is:

category("platelegs", depluralise = false) {
    ...
}

Hopefully we can find a way to make this clearer/remove the requirement for this parameter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably just check if either <name> <category-depluralised> or <name> <category> exists, throwing an error if both do.

@Arham4
Copy link
Contributor Author

Arham4 commented Jul 28, 2018

I've added the fix to the FIXME in my new commit. @Major-

@tlf30
Copy link
Contributor

tlf30 commented Jul 28, 2018

@Arham4 you can modify mine in any way you wish! I put it together as a community resource, and love the idea of it being useful in any way. Like @Major- said, take my numbers with a grain of salt as they did come from previous (half-assed) ports of rs377 and rs317.

@Arham4
Copy link
Contributor Author

Arham4 commented Jul 28, 2018

@tlf30 I found a resource here that matched my shops in both amounts and items. I just converted that JSON file to our Shops DSL. It's 3.3k lines of code, can be found here:

https://pastebin.com/2jWmj7PQ

As you can see, some shops are empty due to them selling OSRS items, so those would need to be filtered. This list also doesn't have the names of the owners. I think it may be a helpful resource for the future to convert to seperate locations, however.

I used the following converter:

package org.apollo.util.tools;

import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import org.apollo.cache.IndexedFileSystem;
import org.apollo.cache.decoder.ItemDefinitionDecoder;
import org.apollo.cache.def.ItemDefinition;

import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Paths;

public class JSONtoPlugin {
	private static class Shop {
		int shopId;
		String name;
		ShopItem[] originalStock;
	}

	private static class ShopItem {
		int id;
		int amount;
	}

	public static void main(String[] args) throws IOException {

		try (IndexedFileSystem fs = new IndexedFileSystem(Paths.get("data/fs/", "377"), true)) {
			ItemDefinitionDecoder decoder = new ItemDefinitionDecoder(fs);
			decoder.run();

			Gson gson = new Gson();
			JsonReader reader = new JsonReader(new FileReader("./data/test/osrsshops.json"));
			Shop[] values = gson.fromJson(reader, Shop[].class);
			for (Shop value : values) {
				System.out.println("shop(\"" + value.name + "\") {");
				System.out.println("\toperated by \"\"");
				System.out.println();
				for (ShopItem shopItem : value.originalStock) {
					if (shopItem.id >= ItemDefinition.count()) {
						continue;
					}
					ItemDefinition definition = ItemDefinition.lookup(shopItem.id);
					if (definition != null) {
						int amount = shopItem.amount == -1 ? 0 : shopItem.amount;
						String id = "(" + shopItem.id + ")";
						boolean duplicates = ItemDefinition.hasDuplicates(definition.getName()) && !ItemDefinition.isFirstItem(definition.getId());
						System.out.println("\tsell(" + amount + ") of \"" + definition.getName() + "\"" + (duplicates ? id : ""));
					}
				}
				System.out.println("}");

			}

		}
	}
}
	public static boolean hasDuplicates(String name) {
		int amount = 0;
		for (ItemDefinition definition : definitions) {
			if (definition.getName() != null) {
				if (definition.getName().equals(name)) {
					amount++;
				}
			}
		}
		return amount > 2;
	}

	public static boolean isFirstItem(int id) {
		String name = lookup(id).getName();
		for (ItemDefinition definition : definitions) {
			if (definition.getName() != null) {
				if (definition.getName().equals(name)) {
					return definition.getId() == id;
				}
			}
		}
		return false;
	}

@tlf30
Copy link
Contributor

tlf30 commented Jul 30, 2018

@Arham4 that looks great, thank you!

@garyttierney
Copy link
Contributor

Any reason why we can't merge this @tlf30 @Major- ?

@Major-
Copy link
Member

Major- commented Aug 21, 2018

Nope, LGTM

@tlf30
Copy link
Contributor

tlf30 commented Aug 21, 2018

Looks good to me!

@Major-
Copy link
Member

Major- commented Aug 22, 2018

Merged in c6cf5a4 .

@Major- Major- closed this Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants