PDA

View Full Version : Mys 1.3.4 Alchemy Mod


Hall of Famer
01-29-2014, 11:21 AM
Well I've had the idea of working on an alchemy system since the initial Mys v1.3.0 release, but did not carry out for numerous reasons. Now I finally decided to give it a try and it took me only about 4-5 hours.

The idea of Alchemy is to mix two old items(called ingredients) to create a new item, which is normally rarer and more valuable(otherwise it does not justify the economics lol). The Alchemy Mod allows you to achieve just that, you can create some items that are rare or even impossible to obtain without performing alchemy. This will make your site considerably more interesting to a good number of your users, it also offers incentives for the act of item collection.

Below is a screenshot of the basic alchemy page, which allows you to choose two items to produce a new one. Note at this time being only two items can be used to produce a new item, there is no way to mix more than two:
http://oi57.tinypic.com/2lxckkg.jpg

This mod also comes with ACP integration, in which the admins can create alchemy practices that allow users to create new items from the old ones. Admins can also manipulate the settings for Alchemy System on their sites. The entire system can be turned on/off at will, while admins can specify whether alchemy success chance is 100% always or less. Other settings such as cost of action, recipe/license requirement for performing alchemy are also configurable.

To install the mod, simply run the installer script located at yoursite.com/install/alchemy.php. If your site is in a subdirectory, just change the example url accordingly. I assume you all know what I mean by this so I wont explain further.

If you have a brand new site or have never ever modified any part of the script, you may simply download the .rar file I provided and uploading them to your server through ftp. If the only changes you made are the mods I've offered lately(gender ratio and item drop), you may give a try just uploading the files as well as good chance my mods are compatible with each other.

However, for advanced users who have heavily modified sites, you will need to make some changes manually. I will post a brief description on how to do that in the next post.

At last, I hope you enjoy the new mod I've made for Mys v1.3.4, unlike the old ones like gender ratio which were simply revised to be compatible with the new version. You can edit the alchemy system to as you wish, maybe altering its user interface or adding more functionality(such as multiple item mix rather than just two), its all up to you.

Hall of Famer

Hall of Famer
01-29-2014, 11:36 AM
For advanced users who have heavily modified sites, you may follow the procedure below to install this mod on your site. Ignore this post if your site works fine with simply uploading/overwriting files.

First of all, upload and run the installer script at yoursite.com/install/alchemy.php. This step is identical for all users, unless you wish to create tables/insert rows into database manually, but will be a pain with this mod.

Second, upload the following new files to your server. Most of these files do not exist in the base script so you wont run into file overwriting problems. The new files are:
/admincp/alchemy.php
/admincp/view/alchemyview.php
/classes/class_alchemy.php
/classes/class_alchemysetting.php
/classes/class_alchemyvalidator.php
/lang/admincp/lang_alchemy.php

You may do the same for the lang file: lang_inventory.php since I assume nobody has ever modified it. If the answer is opposite however, you may wish to search through the differences of the two lang files to see how to append new lang vars to your site. It shouldnt be difficult.

Alright then, in the next step you will need to modify some old script files. I hope you are ready. Now go to file /classes/class_adminsidebar.php and find these line:


$components->add(new Division(new Comment("Inventory", FALSE)));
$inventory = new Division;
$inventory->add(new Link("admincp/inventory/add", "Give Item to User"));
$inventory->add(new Link("admincp/inventory/edit", "Edit User Inventory"));
$inventory->add(new Link("admincp/inventory/delete", "Delete Users items"));
$components->add($inventory);
Add below:


$components->add(new Division(new Comment("Alchemy", FALSE)));
$alchemy = new Division;
$alchemy->add(new Link("admincp/alchemy/add", "Create new Alchemy Practice"));
$alchemy->add(new Link("admincp/alchemy/edit", "Edit Alchemy Practices"));
$alchemy->add(new Link("admincp/alchemy/delete", "Remove Alchemy Practices"));
$alchemy->add(new Link("admincp/alchemy/settings", "Change Alchemy Settings"));
$components->add($alchemy);
Next, go to file /classes/class_itemtablehelper.php and find the constructor:

public function __construct(){
parent::__construct();
}
insert these two methods right below the constructor definition:

/**
* The getItem method, fetches the item type.
* @param int $item
* @access public
* @return String
*/
public function getItem($item){
if(empty($item)) return "N/A";
else return $item;
}

/**
* The getItemImage method, fetches the item image.
* @param id $item
* @access public
* @return Image
*/
public function getItemImage($item){
$item = new Item($item);
$image = new Image($item->imageurl, $item->itemname);
return $image;
}
Then go to script file /inventory.php and find the method toss() at:


public function toss(){
$mysidia = Registry::get("mysidia");
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new ItemException("toss_none");

if($mysidia->input->get("confirm")){
$item->toss();
return;
}
}
Add a new method alchemy() right below it:



public function alchemy(){
$mysidia = Registry::get("mysidia");
$settings = new AlchemySetting($mysidia->db);
if($settings->system == "disabled") throw new ItemException("alchemy_disabled");

if($mysidia->input->post("iid") and $mysidia->input->post("iid2")){
$alchemy = new Alchemy($mysidia->input->post("iid"), $mysidia->input->post("iid2"), $settings);
$alchemy->mix();
$this->setField("alchemy", $alchemy);
return;
}

$stmt = $mysidia->db->select("inventory", array("iid", "itemname"), "owner = '{$mysidia->user->username}'");
$map = $mysidia->db->fetchMap($stmt);
$this->setField("itemMap", $map);
$this->setField("settings", $settings);
}
Now open the file /view/inventoryview.php and find these lines:


$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle($mysidia->lang->inventory);
Add the three new lines below:


$document->addLangvar("You may manage these items as you like, or go to the alchemy page to make your own items: <br>");
$document->add(new Link("inventory/alchemy", "Use the Alchemy Service Now!"));
$document->add(new Comment("<br><br>"));
Next, find the toss() method at:


public function toss(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
if($mysidia->input->get("confirm")){
$document->setTitle($this->lang->global_action_complete);
$document->addLangvar("{$this->lang->toss}{$mysidia->input->post("itemname")}{$this->lang->toss2}");
return;
}

$document->setTitle($this->lang->toss_confirm);
$document->addLangvar($this->lang->toss_warning);

$confirmForm = new FormBuilder("confirmform", "toss/confirm", "post");
$confirmForm->buildPasswordField("hidden", "action", "toss")
->buildPasswordField("hidden", "itemname", $mysidia->input->post("itemname"))
->buildButton("Please Toss", "confirm", "confirm");
$document->add($confirmForm);
}
Append the alchemy() method right below it:


public function alchemy(){
$mysidia = Registry::get("mysidia");
$document = $this->document;

if($mysidia->input->post("iid") and $mysidia->input->post("iid2")){
$alchemy = $this->getField("alchemy");
$newitem = $alchemy->getNewItem()->itemname;
$document->setTitle($this->lang->alchemy_success);
$document->addLangvar($this->lang->alchemy_newitem.$newitem.$this->lang->alchemy_newitem2);
return;
}

$document->setTitle($this->lang->alchemy_title);
$document->addLangvar($this->lang->alchemy);
$itemMap = $this->getField("itemMap");
$settings = $this->getField("settings");
$alchemyFrom = new Form("alchemyform", "alchemy", "post");
$alchemyFrom->add(new Comment("<b>Cost of performing Alchemy: {$settings->cost} {$mysidia->settings->cost}</b><br>"));

$alchemyFrom->add(new Comment($mysidia->lang->alchemy_choose));
$items = new DropdownList("iid");
$items->add(new Option("None Selected", "none"));
if($itemMap->size() > 0){
$iterator = $itemMap->iterator();
while($iterator->hasNext()){
$item = $iterator->nextEntry();
$items->add(new Option($item->getValue(), $item->getKey()));
}
}
$alchemyFrom->add($items);

$alchemyFrom->add(new Comment($mysidia->lang->alchemy_choose2));
$items2 = new DropdownList("iid2");
$items2->add(new Option("None Selected", "none"));
if($itemMap->size() > 0){
$iterator = $itemMap->iterator();
while($iterator->hasNext()){
$item2 = $iterator->nextEntry();
$items2->add(new Option($item2->getValue(), $item2->getKey()));
}
}
$alchemyFrom->add($items2);
$alchemyFrom->add(new Button("Let's mix the items now!", "submit", "submit"));
$document->add($alchemyFrom);
}


At last, open the file /functions/functions_items.php and add a new function to the bottom of the script(right above the php closing tag). It does not really do anything other than preventing some kind of bugs/error messages from possibly emerging:


function items_recipe($item, $adopt){
$note = "The item {$item->itemname} is a recipe item, which cannot be used on any adoptable and can only be useful if you are performing alchemy.";
return $note;
}


You are done with the modifications now, it was easier than you thought right? Anyway you may run into some problems, and in this case please post in this thread to let me know. I will find out where the errors are and fix them for you as soon as I get a chance.

LucasA33
02-02-2014, 11:30 PM
Simply amazing HOF =)
Thanks, might do something like this for evolution stones or something

Abronsyth
02-04-2014, 04:15 PM
I don't suppose it'd be possible to also share a .zip file? I can't work with .rar files :(

Hall of Famer
02-04-2014, 04:17 PM
Sure I can, although an .rar file is not that hard to work with if you download winrar.

Kesstryl
02-04-2014, 10:12 PM
O.O I love it!

Hall of Famer
02-05-2014, 05:14 AM
Oh thanks. ^^ I hope this will be a valuable tiny little addition to your site.

Ruinily
02-05-2014, 10:03 AM
Yeh that is an awesome idea, I wanted something like that on mine ages ago, but I think my coders on hiatus and my photoshops been refusing to work, and I've been busy so I havent had much time for it. ^_^' I know I was playing with the idea of using a system like this to create potions, or make jewellery and trinkets, ect. Is there any chance of this being compatible with older versions of Mysidia? >.>'

Hall of Famer
02-06-2014, 02:53 AM
What version of Mysidia Adoptables are you using? It shouldnt be difficult to get it to work with Mys v1.3.3, but not sure for even older versions.

Ruinily
02-07-2014, 12:01 AM
Lol I'm sticking with 1.3.2... unless I go insane and try to upgrade. XD I was alright until I lost contact with my coder... I'm just praying nothing breaks now. >.>' And its okay if its too hard or difficult, I'll just have to either figure out something else, or just not do it. ^_^'

EDIT: My coders still around! :D She's just busy working on her own site, she said she'll take a quick look at this sometime. ^_^

Abronsyth
02-12-2014, 04:36 PM
Okay, uploaded everything and tried to run the installer, but ran into this;

Warning: require(../inc/config.php): failed to open stream: No such file or directory in /home/ferrepet/public_html/classes/class_initializer.php on line 97

Warning: require(../inc/config.php): failed to open stream: No such file or directory in /home/ferrepet/public_html/classes/class_initializer.php on line 97

Fatal error: require(): Failed opening required '../inc/config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/ferrepet/public_html/classes/class_initializer.php on line 97

Hall of Famer
02-12-2014, 04:39 PM
This is strange, the url rewrite must be malfunctioning on your site. Do you have a .htaccess file in your install folder? If not, create an empty .htaccess file and upload it.

Abronsyth
02-13-2014, 07:45 PM
No, I'll go ahead and try it.

Hall of Famer
02-14-2014, 04:07 AM
Oh btw, the htaccess.txt file in MyBB forum can also be used here. Just rename it as .htaccess and upload it to the install folder if you dont have one in the install directory. The mysidia root directory uses url rewrite, but the install and forum directories do not.

Abronsyth
02-14-2014, 04:56 AM
Uploaded an empty .htaccess file but I am still getting this error;

Warning: require(../inc/config.php): failed to open stream: No such file or directory in /home/ferrepet/public_html/classes/class_initializer.php on line 97

Warning: require(../inc/config.php): failed to open stream: No such file or directory in /home/ferrepet/public_html/classes/class_initializer.php on line 97

Fatal error: require(): Failed opening required '../inc/config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/ferrepet/public_html/classes/class_initializer.php on line 97

I made sure that the file was a .htaccess and not a .txt or anything like that (notepad sometimes messes with that).

Hall of Famer
02-14-2014, 08:01 AM
umm this... I remember you had a similar problem when you were installing the script, I forgot how it was resolved. Do you still remember that? And if you dont mind, send me a PM about your site ftp info and Id like to take a look on why your server is malfunctioning on .htaccess.

Abronsyth
03-12-2014, 11:21 AM
(late reply)
No, don't remember it, unfortunately. I'm having some problems connecting remotely to my site's FTP (something's wrong with the host), so I'll be changing hosts eventually (when I find an affordable one) and then will see about getting this to work again.

Hall of Famer
03-14-2014, 12:47 PM
I see, thats unfortunate. Is there a way you get the FTP to work? Lemme know if I can do anything to help you.

ilrak
09-15-2014, 04:25 PM
(Hopefully my questions make sense. I'm still a bit of a noob when it comes to coding and I'm having issues wording things correctly today)

I'm also having the same issue as Abronsyth with installing this mod. I had similar issues with uploading and installing the gender ratio and item drop mods, but when I manually installed those, it worked fine. Is there a way to fix the issue that's been coming up with this mod that's been discovered (and if so, I'd love to know what so I can add this mod as well!)? If not, what are the tables I need to create so I can manually install this one?

kristhasirah
09-18-2014, 01:09 PM
for those who can't create the database here is the manual install/creation or whatever you want to call it:
just use the "SQL" and copy/paste/change the following codes (remember to change `your_database` for your database name, and if you changed the adopts prefix, remember to change it too to the one you are using):


INSERT INTO `Your_database`.`adopts_acp_hooks` (`id`, `linktext`, `linkurl`, `pluginname`, `pluginstatus`) VALUES ('null', 'Alchemy Plugin v1.3.4 by Hall of Famer', 'http://www.mysidiaadoptables.com/forum/showthread.php?t=4368','alchemy', 'null')


INSERT INTO `Your_database`.`adopts_items_functions` (`ifid`, `function`, `intent`, `description`) VALUES ('null', 'recipe', 'no','This item function defines items that acts as recipe for alchemy practices.')


CREATE TABLE `adopts_alchemy` (alid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, item INT DEFAULT 0, item2 INT DEFAULT 0, newitem INT DEFAULT 0, chance INT DEFAULT 0, recipe INT DEFAULT 0)


CREATE TABLE `adopts_alchemy_settings` (asid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name varchar(20), value varchar(40))


INSERT INTO `Your_database`.`adopts_alchemy_settings` (`asid`, `name`, `value`) VALUES ('1', 'system', 'enabled'), ('2', 'chance', 'enabled'), ('3', 'recipe', 'enabled'), ('4', 'cost', '500'), ('5', 'license', ''), ('6', 'usergroup', 'all')

Please take in mind that this is how it worked for me, im using x10hosting and probably you will have to change/edit something, to make it work.
EDIT:
If you have no idea where to add the codes... I made a failed attempt of tutorial, but it will give you the idea of what to do and where to add the codes:
http://i581.photobucket.com/albums/ss260/kristhasirah/th_tutorialthing.png (http://s581.photobucket.com/user/kristhasirah/media/tutorialthing.png.html) for me is in spanish, but most of the phpadmins are kind of similar

another thing i noticed, while looking at the intall is that the "INT" in most or all of the codes are not in Caps "int" probably this is one of the reasons the install is not working.

hope this help for those who want to install the mod.

by the way: IT WORKS!! THANKS HOF!!!!

Hall of Famer
09-18-2014, 08:50 PM
I am glad the mod is working for everyone, minus the headache of installation. I did beta-test the mod extensively before releasing it, so guess it helps somehow. I aint quite sure why auto-installer aint working for some of you, I will see if theres anything I can do.

kristhasirah
09-19-2014, 08:24 AM
dont worry HOF, for me it was good that the installer dint work ^^ now i know how to insert and create tables XD. and like you said in your first post ._O it was a pain to add them, specially for someone like me that knows too little about coding and creating/inserting/adding tables to a database >_> But for the same reason i decided to add the codes that worked for me to install manually the tables to the database, maybe it will help those who are like me =)

By the way for me the installer only showed a blank page and nothing else... maybe because i used the solution to remove the warnings that appeared in the admin cp...

parayna
09-25-2014, 03:53 PM
I am also having trouble installing this mod ^_^''

This is the warning:

Warning: require(../inc/config.php): failed to open stream: No such file or directory in /home/ycadopts/public_html/classes/class_initializer.php on line 97

Warning: require(../inc/config.php): failed to open stream: No such file or directory in /home/ycadopts/public_html/classes/class_initializer.php on line 97

Fatal error: require(): Failed opening required '../inc/config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/ycadopts/public_html/classes/class_initializer.php on line 97

I tried the installation thing with the tables that kristhasirah said but it didn't work.. not sure what to do XD Help? ^_^

Hall of Famer
09-25-2014, 04:30 PM
Are you using Mys v1.3.4? If so, take a screenshot of the folder structure as it appears on your FTP client and I will see what the error may be.

parayna
09-26-2014, 01:28 AM
Yes I do use the latest version, but what do you mean by 'folder structure'? Do you mean just snapshot an image of the folders? Because I can do that but I'm confused by what you mean XD

kristhasirah
09-26-2014, 09:56 AM
i tested the codes again and they are working, i even created a new database just for that, but if you still have troubles using the codes i posted for installing the tables manually, try installing them 1 by 1 , because if you try to install them all at the same time you must add a: ; at the end of each code
example: CREATE TABLE `adopts_alchemy` (alid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, item INT DEFAULT 0, item2 INT DEFAULT 0, newitem INT DEFAULT 0, chance INT DEFAULT 0, recipe INT DEFAULT 0);
also remember to change the "your_database" with the name of your database
and if your tables have a different "prefix" and not "adopts_" you must change that too

parayna
09-26-2014, 11:40 AM
Oh, OK. I shall try that then! (I did them all at the same time ^_^'') I have just made a copy of my site for testing so now I won't ruin the actual one. So let's see if this works.. XD

EDIT: No... it still won't work.. I keep getting this:

Warning: require(../inc/config.php): failed to open stream: No such file or directory in /home/calamit2/public_html/classes/class_initializer.php on line 97

Warning: require(../inc/config.php): failed to open stream: No such file or directory in /home/calamit2/public_html/classes/class_initializer.php on line 97

Fatal error: require(): Failed opening required '../inc/config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/calamit2/public_html/classes/class_initializer.php on line 97

I don't know if it'll help or not, but here is the class_initializer file:

<?php

use \Resource\Native\Object;
use \Resource\Native\String;

/**
* The Initializer Class, it is responsible for the basic bootstraping of the system.
* It handles basic Loader, Registry, System Object creation, further operations are delegated to Mysidia System Class.
* This is a final class, cannot be extended by any child classes.
* @category Resource
* @package Utility
* @author Hall of Famer
* @copyright Mysidia Adoptables Script
* @link http://www.mysidiaadoptables.com
* @since 1.3.3
* @todo Not much at this point.
* @final
*
*/

final class Initializer extends Object{

/**
* The dir property, defines relative directory for Bootstraping process.
* @access private
* @var String
*/
private $dir;

/**
* The uri property, stores a reference of the URI from server variables.
* @access private
* @var String
*/
private $uri;

/**
* Constructor of Initializer Class, it delegates to the method initialize() to complete the request.
* @access public
* @return Void
*/
public function __construct(){
$this->setURI();
$this->setDir();
$this->initialize();
}

/**
* The getUri method, getter method for property $uri
* @access public
* @return Void
*/
public function getUri(){
return $this->uri;
}

/**
* The setUri method, setter method for property $uri
* The property is set upon Initializer object instantiation, cannot be called from external class.
* @access private
* @return Void
*/
private function setUri(){
$this->uri = $_SERVER['REQUEST_URI'];
}

/**
* The getDir method, getter method for property $dir
* @access public
* @return Void
*/
public function getDir(){
return $this->dir;
}

/**
* The setDir method, setter method for property $dir
* The property is set upon Initializer object instantiation, cannot be called from external class.
* @access private
* @return Void
*/
private function setDir(){
if(strpos($this->uri, "admincp") !== FALSE or strpos($this->uri, "install") !== FALSE){
$this->dir = "../";
}
else $this->dir = "";
}

/**
* The initialize method, carries out the basic bootstraping steps.
* It opens config file first, then include basic files and instantiate important objects.
* @access private
* @return Void
*/
private function initialize(){
$config = "{$this->dir}inc/config.php";
require $config;

include("{$this->dir}functions/functions.php");
include("{$this->dir}functions/functions_users.php");

$loader = "{$this->dir}classes/class_loader.php";
require $loader;
$loader = new Loader($this->dir);

$registry = Registry::getInstance();
Registry::set(new String("loader"), $loader, TRUE, TRUE);

$mysidia = new Mysidia;
$router = new Router($this->uri);
$router->route();
$dispatcher = new Dispatcher($router);
$dispatcher->dispatch();

$wol = new Online;
$wol->update();
Registry::set(new String("wol"), $wol);
}
}
?>

Is there maybe something wrong with it? (That's what the warning seems to say... but I dunno XD)

I know I keep asking for help, but this is the only way I'll learn how to solve issues if I run into them in the future XD (Plus it's a great way of learning basic coding skills hehehe)

kristhasirah
09-26-2014, 12:29 PM
Are you trying to install the mod by using the installer? because your problem is like the one Abronsyth had/has when tried to run the installer.php :http://www.mysidiaadoptables.com/forum/showpost.php?p=28999&postcount=11
The codes i posted are the ones that the installer is supposed to install, so you dont need to run the installer script, just make the edits and upload the required files to make the mod work.

edit:
I did a completely manual Install, because when i tried to run the installer i got a blank page and right now is working without problems or errors.

parayna
09-26-2014, 12:39 PM
Oooh! So i just ignore the install folder and manually install everything else? I can try that! Thanks!

kristhasirah
09-26-2014, 12:49 PM
Yes, if you used the codes i posted then you already have installed the tables you need for the mod and now just need to edit the pages and add the files, and the mod will be working without problems =)

parayna
09-26-2014, 01:35 PM
Nope, it still won't work... where do you insert the table codes? Because I have tried all the files and the only one that I can find is the alchemy.php file in the install folder. But it has the install thing in it and won't work if I just put it into the public html folder...

i might just create the tables manually... do you know what I need to put in each box? (Like NULL etc.) I tried a moment ago but the silly thing kept popping up with an error (I don't know everything to put in the boxes.. what values etc.)

EDIT:

Well, i think I may be figuring it out. I am entering the table things into the manual creation thing in x10 hosting and now I am trying to get the lines to work and get the codes creating the table. But it keeps coming up with errors..

EDIT 2:

Yay! It worked! Thank you! I got it working ^_^

kristhasirah
09-26-2014, 02:11 PM
=D im glad that is working for you now!!!
sorry for my failed attempt of explaining how to add the codes in the database, English is not my native language, but i will add some pictures of where to add the codes in the database

parayna
09-26-2014, 02:36 PM
OK XD It actually turned out it has created a blank database >.< But now that all the other boxes are gone and the only ones left are asid, name and value, I'm hoping it'll work! I am almost finished, so I'll edit this if it works or not... I'm hoping it will XD

EDIT:

Yep! It worked! :D Thanks! And you didn't do too badly with explaining, I just understand little to no coding at all XD So I am trying to learn, but I am only, like, a teenager so... XD I am attempting to pick bits up though so that I will be able to do things like this in future! (Without too much help :P)

kristhasirah
09-26-2014, 02:51 PM
well i made a failed attempt of tutorial for those that have no idea of how to add or create a table in the database... i was like that at first... and still have problems, so probably i will be coming back to see my failed attempt in a near future, as i usually forget how i added or edited something >_>"

http://i581.photobucket.com/albums/ss260/kristhasirah/th_tutorialthing.png (http://s581.photobucket.com/user/kristhasirah/media/tutorialthing.png.html)
this is how i add them to the database, if you are using x10hosting when you open phpmyadmin you must click the name of your database is the one down of information_schema, that way you are sure that you are adding creating and inserting the info in the correct database

the first 2 inserts are the ones i think they can give you problems, but is easy to add the values manually,
just click the the adopts_acp_hooks, wait for the table to load and click insert/insertar, it will open a new window and just add this:
first box leave it blank
2nd: Alchemy Plugin v1.3.4 by Hall of Famer
3rd: http://www.mysidiaadoptables.com/forum/showthread.php?t=4368
4th: alchemy
5th: null
For the second insert do the same: click adpts_items_functions, click insert/insertar, wait for the new window and add the following info
First box: leave it blank
2nd: recipe
3rd: no
4th: This item function defines items that acts as recipe for alchemy practices.

the other 3 are working, i tested them 3 times in a new database, but like i say make sure you have selected the database you are using for your site.

Edit:

Glad to know is now working for you ^_^ !!!

parayna
09-26-2014, 03:08 PM
Yeah, I use x10 hosting. XD And it wouldn't insert the items into the settings database so I was lucky that it created a blank one (the adopts_alchemy_settings thing) as then it was easy to go through and add them myself by adding values XD And I'm sure the tutorial will help a few others who are stuck! :D

AndromedaKerova
12-06-2014, 03:54 PM
I'm having problems with the alchemy mod. I installed everything but when I try to create a new alchemy, it throws this at me after clicking submit: Database error 1146 - Table 'chibifur_chibifurs.adopts_alchemy' doesn't exist

I went through all the files and they are all configured properly.

Kyttias
12-07-2014, 07:23 AM
Are you using adopts_ as your table prefix in your database?

And to make sure, did you create the tables first? This post a few pages back (http://www.mysidiaadoptables.com/forum/showpost.php?p=31118&postcount=20) helps.

AndromedaKerova
12-07-2014, 03:21 PM
Yeah. adopts is the prefix. Thought it would be a bit confusing later if I had changed it so I left it as it was.

I just tried the codes and the last one failed.
It refuses to insert contents into the adopts_alchemy_settings table.

The adopts_alchemy table is created and has the contents.
The adopts_alchemy_settings is created and has no contents.

I use x10 hosting as well.

The code to insert contents into the adopts_alchemy_settings table says this error:
#1142 - INSERT command denied to user 'chibifur'@'localhost' for table 'adopts_alchemy_settings'

Sorry if it's not clear. I'm not very good with formatting things.

Kyttias
12-07-2014, 06:39 PM
Well, hmmm. While Google implies this is normally a permissions issue, I also had trouble using the supplied SQL commands to insert data into the table on my own server (tested just now).

So I took a look at it. I visited the database and hit SQL to create the table first -
CREATE TABLE `adopts_alchemy_settings` (asid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name varchar(20), value varchar(40))
Then went into the table and hit SQL again to insert the data there -
INSERT INTO `adopts_alchemy_settings` (`asid`, `name`, `value`) VALUES (1, 'system', 'enabled'), (2, 'chance', 'enabled'), (3, 'recipe', 'enabled'), (4, 'cost', '500'), (5, 'license', ''), (6, 'usergroup', 'all')
http://fc08.deviantart.net/fs71/f/2014/341/9/9/help_by_kyttias-d892d6q.gif

I changed the formatting only slightly? And it seemed to help. But the order of operations I think is what really helped, rather than doing it all from the front of the database - to do it while already visiting the table. Try that with the others, too?

AndromedaKerova
12-07-2014, 06:49 PM
I've got it to finally do the job now. Oddly I didn't do anything different and it worked.
Alchemy is completely functional. Tested and verified.

Only a few more issues to work on like the failing gender ratio and figuring out to add an explore system with chances of getting items, pets and coins and then my site should be ready for visitors.

On a side note, How did you make that gif? It's really clever and useful o see what to do almost live.

Kyttias
12-07-2014, 06:54 PM
^^ It's quite fun! The program has got the dumbest name, LICEcap (http://www.cockos.com/licecap/).

Glow
12-31-2014, 02:05 AM
Uhmm sorry but I have some troubles, I am still unable to install this alchemy thing. I have created the tables already and downloaded the file, and have not done any other Mods to the site as of yet, any help or reasons why it did not work?

AndromedaKerova
01-09-2015, 11:01 PM
I'm having a problem with this mod. After adding it, using an item on a pet just leads to a pure white /uses page.

Phoeniix
02-02-2015, 04:23 PM
Well I've had the idea of working on an alchemy system since the initial Mys v1.3.0 release, but did not carry out for numerous reasons. Now I finally decided to give it a try and it took me only about 4-5 hours.

The idea of Alchemy is to mix two or more old items(called ingredients) to create a new item, which is normally rarer and more valuable(otherwise it does not justify the economics lol). The Alchemy Mod allows you to achieve just that, you can create some items that are rare or even impossible to obtain without performing alchemy. This will make your site considerably more interesting to a good number of your users, it also offers incentives for the act of item collection.

Below is a screenshot of the basic alchemy page, which allows you to choose two items to produce a new one. Note at this time being only two items can be used to produce a new item, there is no way to mix more than two:
http://oi57.tinypic.com/2lxckkg.jpg

This mod also comes with ACP integration, in which the admins can create alchemy practices that allow users to create new items from the old ones. Admins can also manipulate the settings for Alchemy System on their sites. The entire system can be turned on/off at will, while admins can specify whether alchemy success chance is 100% always or less. Other settings such as cost of action, recipe/license requirement for performing alchemy are also configurable.

To install the mod, simply run the installer script located at yoursite.com/install/alchemy.php. If your site is in a subdirectory, just change the example url accordingly. I assume you all know what I mean by this so I wont explain further.

If you have a brand new site or have never ever modified any part of the script, you may simply download the .rar file I provided and uploading them to your server through ftp. If the only changes you made are the mods I've offered lately(gender ratio and item drop), you may give a try just uploading the files as well as good chance my mods are compatible with each other.

However, for advanced users who have heavily modified sites, you will need to make some changes manually. I will post a brief description on how to do that in the next post.

At last, I hope you enjoy the new mod I've made for Mys v1.3.4, unlike the old ones like gender ratio which were simply revised to be compatible with the new version. You can edit the alchemy system to as you wish, maybe altering its user interface or adding more functionality(such as multiple item mix rather than just two), its all up to you.

Hall of Famer
I am having some trouble with the alchemy mod.
I unzipped the folder and put install/alchemy.php and its a blank screen

cailynmae
03-30-2015, 03:35 PM
I ran the installer script and got:
Warning: require(../inc/config.php) [function.require]: failed to open stream: No such file or directory in /home2/luteus/public_html/imaginea.net/caveofcrystals/classes/class_initializer.php on line 97

Warning: require(../inc/config.php) [function.require]: failed to open stream: No such file or directory in /home2/luteus/public_html/imaginea.net/caveofcrystals/classes/class_initializer.php on line 97

Fatal error: require() [function.require]: Failed opening required '../inc/config.php' (include_path='.:/opt/php53/lib/php') in /home2/luteus/public_html/imaginea.net/caveofcrystals/classes/class_initializer.php on line 97

Any idea what's going on?

Kyttias
03-30-2015, 06:52 PM
Have you attempted the fix already posted inside this thread? That is, manually installing? Read through the entire thread before proceeding and then if that doesn't work, come back. I don't use this mod myself but I can try to help but only if you've already tried the help already posted.

cailynmae
04-04-2015, 10:55 AM
Okay, I did the whole super-manual thing, and it seemed to work. But then I went to the alchemy page, and got this:
Fatal error: Uncaught exception 'LanguageException' with message 'Language var alchemy_title does not exist.' in /home2/luteus/public_html/imaginea.net/caveofcrystals/classes/class_language.php:68 Stack trace: #0 /home2/luteus/public_html/imaginea.net/caveofcrystals/view/inventoryview.php(162): Language->__get('alchemy_title') #1 /home2/luteus/public_html/imaginea.net/caveofcrystals/classes/class_frontcontroller.php(100): InventoryView->alchemy() #2 /home2/luteus/public_html/imaginea.net/caveofcrystals/index.php(74): FrontController->render() #3 /home2/luteus/public_html/imaginea.net/caveofcrystals/index.php(78): IndexController::main() #4 {main} thrown in /home2/luteus/public_html/imaginea.net/caveofcrystals/classes/class_language.php on line 68

I then went in and added this to the bottom of /lang/lang_inventory.php:

$lang['alchemy_title'] = "Welcome to the Alchemy Service";
$lang['alchemy'] = "Here you can use the powerful alchemy system to merge two of your items to produce a new item, whether brand new or not.
Fill in the form below to start using this service we offer, you may find plenty of surprises!";
$lang['alchemy_choose'] = "To begin with, select the first ingredient item from the list: ";
$lang['alchemy_choose2'] = "Now select the second ingredient item from the list: ";
$lang['alchemy_disabled'] = "Unfortunately the admin has disabled the Alchemy System for this site, you may send him/her a message for more information.";
$lang['alchemy_success'] = "Congratulations!";
$lang['alchemy_newitem'] = "You have successfully produced a new item ";
$lang['alchemy_newitem2'] = " by using Alchemy, sweet isnt it? You may now manage it in your inventory, or continue to use the alchemy system.";
$lang['alchemy_invalid'] = "The specified item combination is invalid, it does not produce a new item...";
$lang['alchemy_empty'] = "You have not entered two valid items for doing alchemy.";
$lang['alchemy_insufficient'] = "You do not have the necessary items for producing a new item through alchemy.";
$lang['alchemy_chance'] = "The alchemy fails! How unfortunate, maybe you wanna try again with better effort?";
$lang['alchemy_cost'] = "Apparently you do not have enough money to afford the alchemy service, please come back later.";
$lang['alchemy_license'] = "You appear to lack the license required to perform alchemy, please make sure you have the license in your inventory first.";
$lang['alchemy_recipe'] = "It seems that you do not have the recipe to produce an item from the two selected items.";
$lang['alchemy_usergroup'] = "Unfortunately, the admin has specified that only certain users can perform alchemy, you may consult him/her by sending a message.";
There is something missing in the manual install thing, but I found a fix in case someone had this problem. Everything else seems to be working fine, thankfully.

draugluin
04-24-2015, 06:48 AM
I need a little bit help please.

I would like to show the image, which item the users have produced.
What have I change ?

Thanks

Nieth
11-13-2015, 12:13 PM
As a continuation from my other thread,

I had sorta figured that making the mod diverse would be a bit more complex so we came up with a work around.

One more question, is there a way to make the mod not care about the order the items are inserted into it? Like for example if there's a crafting recipe that calls for:

Item1, Item2

or

Item1, Item1, Item2

How can I make it so that it will create the item if you put in:

Item2, Item1

or

Item2, Item1, Item2

As the mod is currently set up the items have to be inserted in the exact same order as it was created in the acp.

Hall of Famer
11-13-2015, 12:57 PM
I think the mod already handles items in reverse order. So if Item 1/Item 2 works, Item2/Item 1 should work too. Are you sure it doesnt work for you?

Nieth
11-13-2015, 01:09 PM
I didn't try the original, but in the one I edited, I believe I allowed for the order. It doesn't seem to work though.

../admincp/alchemy.php @ line 85
I changed:
$whereClause = "(item = {$mysidia->input->post("item")} and item2 = {$mysidia->input->post("item2")}) OR (item = {$mysidia->input->post("item2")} and item2 = {$mysidia->input->post("item")})";

to
$whereClause = "(item = {$mysidia->input->post("item")} and item2 = {$mysidia->input->post("item2")} and item3 = {$mysidia->input->post("item3")}) OR (item = {$mysidia->input->post("item")} and item3 = {$mysidia->input->post("item3")} and item2 = {$mysidia->input->post("item2")}) OR (item2 = {$mysidia->input->post("item2")} and item = {$mysidia->input->post("item")} and item3 = {$mysidia->input->post("item3")}) OR (item2 = {$mysidia->input->post("item2")} and item3 = {$mysidia->input->post("item3")} and item = {$mysidia->input->post("item")}) OR (item3 = {$mysidia->input->post("item3")} and item2 = {$mysidia->input->post("item2")} and item = {$mysidia->input->post("item")}) OR (item3 = {$mysidia->input->post("item3")} and item = {$mysidia->input->post("item")} and item2 = {$mysidia->input->post("item2")})";

and I changed ../classes/class_alchemy.php @ line 27
from:
$whereClause = "(item = {$this->item->id} and item2 = {$this->item2->id}) OR (item = {$this->item2->id} and item2 = {$this->item->id})";

to
$whereClause = "(item = {$this->item->id} and item2 = {$this->item2->id} and item3 = {$this->item3->id}) OR (item = {$this->item->id} and item3 = {$this->item3->id} and item2 = {$this->item2->id}) OR (item2 = {$this->item2->id} and item = {$this->item->id} and item3 = {$this->item3->id}) OR (item2 = {$this->item2->id} and item3 = {$this->item3->id} and item = {$this->item->id}) OR (item3 = {$this->item3->id} and item2 = {$this->item2->id} and item = {$this->item->id}) OR (item3 = {$this->item3->id} and item = {$this->item->id} and item2 = {$this->item2->id})";

Didn't seem to work. Don't know if I did something wrong or not.

Hall of Famer
11-13-2015, 01:22 PM
Of course it doesnt work, because you are just reversing the order of the WHERECLAUSE, rather than changing the actual content. In your sample code, these two are equivalent, and make no difference:


item = {$mysidia->input->post("item")} and item2 = {$mysidia->input->post("item2")} and item3 = {$mysidia->input->post("item3")}
vs


item2 = {$mysidia->input->post("item2")} and item = {$mysidia->input->post("item")} and item3 = {$mysidia->input->post("item3")}
Do you understand what I mean? Lets consider this example. To say 'you have an apple and your friend has a banana', or to say 'your friend has a banana and you have an apple', it means the same thing. You are just reversing the logical order of the statement, but doesnt change the fact that apple belongs to you and banana belong to your friend. But its different if you say 'you have a banana and your friend has an apple', since in this case banana belongs to you and apple belongs to your friend. Now you can have either apple or banana, and so are with your friend. Sorry if I aint good at explaining, but I hope you get the idea.

Nieth
11-13-2015, 01:33 PM
Oh, wow. I see the difference in the first statement now, I can't believe I overlooked that the first time. Thanks a bunch. I'mma rewrite it a bit, I'm sure I'll be able to get it to work this time. xD

Man, I feel so stupid for not noticing the placements.

I just need to figure out how many different 'OR's that I need now.

EDIT: Yep, all good and functional now. Thanks for the help, still new to trying to program/edit stuff.

Hall of Famer
11-13-2015, 02:37 PM
You are very welcome, I am glad I can help. You can also try SQL IN clause, so you will get rid of the OR operators. However, you will need to compare each user input, ie. $mysidia->input->post("item"), and $mysidia->input->post("item2") so that your users wont enter the same item for item1, item2, etc. Here is an example for two items SQL:


$items = "({$mysidia->input->post('item')}, {$mysidia->input->post('item2')})";
$whereClause = "(item IN {$items} and item2 IN $items)";


Read the below tutorial on w3schools, and it will help:
http://www.w3schools.com/sql/sql_in.asp

Nieth
11-13-2015, 03:18 PM
Ah, alright! Thanks again, I'm learning so much by messing around with everything, realizing what means what etc. Still a complete beginner, but learning is still learning.

Would there be a simple way to change the URL for the alchemy stuff or would that be too difficult to do?

Also, where can the alchemy page be edited? I'd like to add images and specific things to that page, but I can't find where to edit it.

Hall of Famer
11-18-2015, 01:44 AM
Well there are two view files you can edit to add images and other specific things to the alchemy page:
/view/inventoryview.php
/admincp/view/alchemyview.php

Note you need to understand GUI programming in order to make changes, its not the HTML a front end designer may be familiar with. The style of coding is similar to Java swing, so if you understand how swing works, it will be easy for you.

Nieth
11-18-2015, 05:45 AM
Yeah, I figured out after reading some guides that I would have to edit the view pages to change what the user sees, so I went in there and tried looking around to see what made sense. Absolutely nothing! So, I've decided to leave that alone until I've reached a bit more advanced stage.

Hall of Famer
11-18-2015, 12:41 PM
Its not actually that hard to understand, you just need some OOP skills and understand how the composite design pattern works. I would recommend you to read the tutorial for Java swing, and after going through it you should have no problem dealing with Mysidia's GUI API(although you will need basic Java programming knowledge to follow the tutorial):
http://www.tutorialspoint.com/swing/

SapphirePhoenix
11-30-2015, 02:31 PM
Which file am I supposed to upload the file into?

Nieth
11-30-2015, 03:58 PM
Using the FTP, you upload the contents of the folder to the public_html folder. All the directories should split and upload into their appropriate folders so long as you do it correctly.

Abronsyth
12-18-2015, 10:12 AM
Anyone know what this error means?


Database error 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and item2 = 30) OR (item = 30 and item2 = )' at line 2

It happened just as I tried to combine 2 of the items for one of my alchemy recipes.

Edit: It still made the item, but for some reason that error came up instead of a success message.

Corsair
02-10-2016, 06:51 PM
I seem to be seeing this error on the Alchemy page

Strict Standards: Declaration of DropdownList::add() should be compatible with GUIContainer::add(GUIComponent $component, $index = -1) in /home/monstari/public_html/classes/class_dropdownlist.php on line 184

Ittermat
03-01-2016, 10:08 PM
I was trying to install this mod and Itemdrop- but when I go to my admin CP and try to edit a users inventory, I get this error-

Fatal Error: Class ACPInventoryController either does not exist, or has its include path misconfigured!

I have gone through and attempted to redo everything I did for both mods...(without ruining anything else) but nothing seems to be working.. x.x

Pear
03-30-2016, 05:45 PM
How do I get to the alchemy page? |D /alchemy does not work. |D Do I need to make an alchemy page?

Kyttias
03-30-2016, 06:45 PM
I think it's part of the inventory page?

Ittermat
03-30-2016, 06:48 PM
yea its inventory/alchemy

Pear
03-30-2016, 07:06 PM
Ah, okay. Thanks guys. |D I haven't put any of my items up on my site yet so it just says that I don't have any items yet..x)

LUC1G07CH1
04-06-2016, 05:45 PM
After installing this mod i cannot add new pets! Help!

That mesage just appears:
Strict Standards: Declaration of AdminSidebar::setDivision() should be compatible with Sidebar::setDivision(GUIComponent $module) in /home/enchante/public_html/classes/class_adminsidebar.php on line 18

And i cannot create an pet anymore.

Edit: And also Alchemy don't works,even that i installed.
Fatal error: Call to undefined method InventoryView::alchemy() in /home/enchante/public_html/classes/class_frontcontroller.php on line 100

Argh annoying errors!

tahbikat
04-07-2016, 02:12 AM
Works great so far! I too get a weird error like Luci's in my ACP, but it doesn't affect anything for me. Just a little annoying to look at.


Strict Standards: Declaration of AdminSidebar::setDivision() should be compatible with Sidebar::setDivision(GUIComponent $module) in /home/mysgardia/public_html/classes/class_adminsidebar.php on line 18

LUC1G07CH1
04-07-2016, 08:35 AM
I got weirdo text on my Admin CP,but for adding an adoptable...Goodbye million of Encarses...

tahbikat
04-16-2016, 01:52 AM
Okay... so I discovered if I combine two of the same item it only uses 1 instead of taking away two. So for example:

I have 2 Apples in my inventory.
If I combine 1 apple with 1 apple to get an orange, only 1 apple is used and I still get the orange.

Is there a way to change this so it consumes the proper quantity (2)?

Corsair
11-27-2016, 10:27 PM
I'm trying to figure out how to make it that you can mix three items instead of the default two. I tried but I messed up and had to restore the old files.

Abronsyth
11-28-2016, 10:38 AM
I believe it already has a setting that you can sort of use three, with one being a "recipe" item or something like that? I haven't played around with it enough to know for sure, though.

Corsair
11-28-2016, 10:56 AM
I was hoping to have 3 plus a "recipe" item.

Dinocanid
11-28-2016, 06:54 PM
I was able to do it, or at least it works fine on my end. (If it doesn't work, I forgot something) This is what I did:

First go to phpMyAdmin and add another column in adopts_alchemy called item3 with the exact same settings as item and item2.

<?php

class ACPAlchemyController extends AppController{

const PARAM = "alid";

public function __construct(){
parent::__construct();
$mysidia = Registry::get("mysidia");
if($mysidia->usergroup->getpermission("canmanagesettings") != "yes"){
throw new NoPermissionException("You do not have permission to manage alchemy.");
}
}

public function index(){
parent::index();
$mysidia = Registry::get("mysidia");
$stmt = $mysidia->db->select("alchemy");
$num = $stmt->rowCount();
if($num == 0) throw new InvalidIDException("default_none");
$this->setField("stmt", new DatabaseStatement($stmt));
}

public function add(){
$mysidia = Registry::get("mysidia");
if($mysidia->input->post("submit")){
$this->dataValidate();
$mysidia->db->insert("alchemy", array("alid" => NULL, "item" => $mysidia->input->post("item"), "item2" => $mysidia->input->post("item2"),
"newitem" => $mysidia->input->post("newitem"), "chance" => $mysidia->input->post("chance"), "recipe" => $mysidia->input->post("recipe"), "item3" => $mysidia->input->post("item3")));
}
$this->loadItemMap();
}

public function edit(){
$mysidia = Registry::get("mysidia");
if(!$mysidia->input->get("alid")){
// An item has yet been selected, return to the index page.
$this->index();
return;
}
elseif($mysidia->input->post("submit")){
$this->dataValidate();
$mysidia->db->update("alchemy", array("item" => $mysidia->input->post("item"), "item2" => $mysidia->input->post("item2"),"item3" => $mysidia->input->post("item3"), "newitem" => $mysidia->input->post("newitem"),
"chance" => $mysidia->input->post("chance"), "recipe" => $mysidia->input->post("recipe")), "alid='{$mysidia->input->get("alid")}'");
return;
}
else{
$alchemy = $mysidia->db->select("alchemy", array(), "alid='{$mysidia->input->get("alid")}'")->fetchObject();
if(!is_object($alchemy)) throw new InvalidIDException("nonexist");
$this->setField("alchemy", new DataObject($alchemy));
$this->loadItemMap();
}
}

public function delete(){
$mysidia = Registry::get("mysidia");
if(!$mysidia->input->get("alid")){
// An item has yet been selected, return to the index page.
$this->index();
return;
}
$mysidia->db->delete("alchemy", "alid='{$mysidia->input->get("alid")}'");
}

public function settings(){
$mysidia = Registry::get("mysidia");
$alchemySettings = new AlchemySetting($mysidia->db);
if($mysidia->input->post("submit")){
$settings = array('system', 'chance', 'recipe', 'cost', 'license', 'usergroup');
foreach($settings as $name){
if($mysidia->input->post($name) != ($alchemySettings->$name)) $mysidia->db->update("alchemy_settings", array("value" => $mysidia->input->post($name)), "name='{$name}'");
}
return;
}
$this->setField("alchemySettings", $alchemySettings);
}

private function dataValidate(){
$mysidia = Registry::get("mysidia");
if(!$mysidia->input->post("item") or !is_numeric($mysidia->input->post("item"))) throw new BlankFieldException("item");
if(!$mysidia->input->post("item2") or !is_numeric($mysidia->input->post("item2"))) throw new BlankFieldException("item2");
if(!$mysidia->input->post("item3") or !is_numeric($mysidia->input->post("item3"))) throw new BlankFieldException("item3");

if($mysidia->input->action() == "add"){
$whereClause = "(item = {$mysidia->input->post("item")} and item2 = {$mysidia->input->post("item2")} and item3 = {$mysidia->input->post("item3")}) OR (item = {$mysidia->input->post("item2")} and item2 = {$mysidia->input->post("item")} and item = {$mysidia->input->post("item3")})";
$alchemy = $mysidia->db->select("alchemy", array(), $whereClause)->fetchObject();
if(is_object($alchemy)) throw new DuplicateIDException("duplicate");
}

if(!$mysidia->input->post("newitem")) throw new BlankFieldException("newitem");
if($mysidia->input->post("chance") < 0 or $mysidia->input->post("chance") > 100) throw new InvalidActionException("chance");
header("Refresh:3; URL='../../index'");
return TRUE;
}

private function loadItemMap(){
$mysidia = Registry::get("mysidia");
$stmt = $mysidia->db->select("items", array("id", "itemname"));
$map = $mysidia->db->fetchMap($stmt);
$this->setField("itemMap", $map);
$stmt2 = $mysidia->db->select("items", array("id", "itemname"), "function = 'Recipe'");
$map2 = $mysidia->db->fetchMap($stmt2);
$this->setField("recipeMap", $map2);
}
}
?>
(alchemy.php)

<?php

use Resource\Native\String;
use Resource\Collection\LinkedHashMap;

class ACPAlchemyView extends View{

public function index(){
parent::index();
$mysidia = Registry::get("mysidia");
$stmt = $this->getField("stmt")->get();
$document = $this->document;

$fields = new LinkedHashMap;
$fields->put(new String("alid"), NULL);
$fields->put(new String("item"), new String("getItemImage"));
$fields->put(new String("item2"), new String("getItemImage"));
$fields->put(new String("item3"), new String("getItemImage"));
$fields->put(new String("newitem"), new String("getItemImage"));
$fields->put(new String("alid::edit"), new String("getEditLink"));
$fields->put(new String("alid::delete"), new String("getDeleteLink"));

$AlchemyTable = new TableBuilder("alchemy");
$AlchemyTable->setAlign(new Align("center", "middle"));
$AlchemyTable->buildHeaders("ID", "Item1", "Item2","Item3", "New Item", "Edit", "Delete");
$AlchemyTable->setHelper(new ItemTableHelper);
$AlchemyTable->buildTable($stmt, $fields);
$document->add($AlchemyTable);
}

public function add(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
if($mysidia->input->post("submit")){
$document->setTitle($this->lang->added_title);
$document->addLangvar($this->lang->added);
return;
}

$document->setTitle($this->lang->add_title);
$document->addLangvar($this->lang->add);
$itemMap = $this->getField("itemMap");
$recipeMap = $this->getField("recipeMap");

$alchemyForm = new Form("createalchemy", "add", "post");
$title = new Comment("Create new Alchemy Practice:");
$title->setBold();
$title->setUnderlined();
$alchemyForm->add($title);

$alchemyForm->add(new Comment("Select first ingredient item: ", FALSE));
$items = new DropdownList("item");
$items->add(new Option("None Selected", "none"));
if($itemMap->size() > 0){
$iterator = $itemMap->iterator();
while($iterator->hasNext()){
$item = $iterator->nextEntry();
$items->add(new Option($item->getValue(), $item->getKey()));
}
}
$alchemyForm->add($items);

$alchemyForm->add(new Comment("Select second ingredient item: ", FALSE));
$items2 = new DropdownList("item2");
$items2->add(new Option("None Selected", "none"));
if($itemMap->size() > 0){
$iterator = $itemMap->iterator();
while($iterator->hasNext()){
$item2 = $iterator->nextEntry();
$items2->add(new Option($item2->getValue(), $item2->getKey()));
}
}
$alchemyForm->add($items2);

$alchemyForm->add(new Comment("Select third ingredient item: ", FALSE));
$items3 = new DropdownList("item3");
$items3->add(new Option("None Selected", "none"));
if($itemMap->size() > 0){
$iterator = $itemMap->iterator();
while($iterator->hasNext()){
$item3 = $iterator->nextEntry();
$items3->add(new Option($item3->getValue(), $item3->getKey()));
}
}
$alchemyForm->add($items3);

$alchemyForm->add(new Comment("Select newly produced item: ", FALSE));
$newitems = new DropdownList("newitem");
$newitems->add(new Option("None Selected", "none"));
if($itemMap->size() > 0){
$iterator = $itemMap->iterator();
while($iterator->hasNext()){
$newitem = $iterator->nextEntry();
$newitems->add(new Option($newitem->getValue(), $newitem->getKey()));
}
}
$alchemyForm->add($newitems);
$alchemyForm->add(new Comment("Chance for Alchemy to work: ", FALSE));
$alchemyForm->add(new TextField("chance", 100, 6));

$alchemyForm->add(new Comment("Select recipe item: ", FALSE));
$recipes = new DropdownList("recipe");
$recipes->add(new Option("None Selected", "none"));
if($recipeMap->size() > 0){
$iterator = $recipeMap->iterator();
while($iterator->hasNext()){
$recipe = $iterator->nextEntry();
$recipes->add(new Option($recipe->getValue(), $recipe->getKey()));
}
}
$alchemyForm->add($recipes);
$alchemyForm->add(new Button("Create New Alchemy Practice", "submit", "submit"));
$document->add($alchemyForm);
}

public function edit(){
$mysidia = Registry::get("mysidia");
$document = $this->document;

if(!$mysidia->input->get("alid")){
// An item has yet been selected, return to the index page.
$this->index();
return;
}
elseif($mysidia->input->post("submit")){
$document->setTitle($this->lang->edited_title);
$document->addLangvar($this->lang->edited);
return;
}
else{
$alchemy = $this->getField("alchemy")->get();
$document->setTitle($this->lang->edit_title);
$document->addLangvar($this->lang->edit);
$title = new Comment("Edit Alchemy Practice:");
$title->setBold();
$title->setUnderlined();

$alchemyForm = new Form("edititem", $mysidia->input->get("alid"), "post");
$alchemyForm->add($title);
$alchemyForm->add(new Comment("Select first ingredient item: ", FALSE));
$itemMap = $this->getField("itemMap");
$recipeMap = $this->getField("recipeMap");

$items = new DropdownList("item");
$items->add(new Option("None Selected", "none"));
if($itemMap->size() > 0){
$iterator = $itemMap->iterator();
while($iterator->hasNext()){
$item = $iterator->nextEntry();
$items->add(new Option($item->getValue(), $item->getKey()));
}
}
$items->select($alchemy->item);
$alchemyForm->add($items);

$alchemyForm->add(new Comment("Select second ingredient item: ", FALSE));
$items2 = new DropdownList("item2");
$items2->add(new Option("None Selected", "none"));
if($itemMap->size() > 0){
$iterator = $itemMap->iterator();
while($iterator->hasNext()){
$item2 = $iterator->nextEntry();
$items2->add(new Option($item2->getValue(), $item2->getKey()));
}
}
$items2->select($alchemy->item2);
$alchemyForm->add($items2);

$alchemyForm->add(new Comment("Select third ingredient item: ", FALSE));
$items3 = new DropdownList("item3");
$items3->add(new Option("None Selected", "none"));
if($itemMap->size() > 0){
$iterator = $itemMap->iterator();
while($iterator->hasNext()){
$item3 = $iterator->nextEntry();
$items3->add(new Option($item3->getValue(), $item3->getKey()));
}
}
$items3->select($alchemy->item3);
$alchemyForm->add($items3);

$alchemyForm->add(new Comment("Select newly produced item: ", FALSE));
$newitems = new DropdownList("newitem");
$newitems->add(new Option("None Selected", "none"));
if($itemMap->size() > 0){
$iterator = $itemMap->iterator();
while($iterator->hasNext()){
$newitem = $iterator->nextEntry();
$newitems->add(new Option($newitem->getValue(), $newitem->getKey()));
}
}
$newitems->select($alchemy->newitem);
$alchemyForm->add($newitems);
$alchemyForm->add(new Comment("Chance for Alchemy to work: ", FALSE));
$alchemyForm->add(new TextField("chance", $alchemy->chance, 6));

$alchemyForm->add(new Comment("Select recipe item: ", FALSE));
$recipes = new DropdownList("recipe");
$recipes->add(new Option("None Selected", "none"));
if($recipeMap->size() > 0){
$iterator = $recipeMap->iterator();
while($iterator->hasNext()){
$recipe = $iterator->nextEntry();
$recipes->add(new Option($recipe->getValue(), $recipe->getKey()));
}
}
$recipes->select($alchemy->recipe);
$alchemyForm->add($recipes);

$alchemyForm->add(new Button("Edit Alchemy Practice", "submit", "submit"));
$document->add($alchemyForm);
}
}

public function delete(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
if(!$mysidia->input->get("alid")){
// An entry has yet been selected, return to the index page.
$this->index();
return;
}
$document->setTitle($this->lang->delete_title);
$document->addLangvar($this->lang->delete);
}

public function settings(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
if($mysidia->input->post("submit")){
$document->setTitle($this->lang->settings_changed_title);
$document->addLangvar($this->lang->settings_changed);
return;
}

$alchemySettings = $this->getField("alchemySettings");
$document->setTitle($this->lang->settings_title);
$document->addLangvar($this->lang->settings);
$settingsForm = new FormBuilder("settingsform", "settings", "post");
$alchemySystem = new LinkedHashMap;
$alchemySystem->put(new String("Enabled"), new String("enabled"));
$alchemySystem->put(new String("Disabled"), new String("disabled"));
$alchemyChance = clone $alchemySystem;
$alchemyRecipe = clone $alchemySystem;

$settingsForm->buildComment("Alchemy System Enabled: ", FALSE)->buildRadioList("system", $alchemySystem, $alchemySettings->system)
->buildComment("Alchemy Success/Failure Enabled: ", FALSE)->buildRadioList("chance", $alchemyChance, $alchemySettings->chance)
->buildComment("Alchemy Recipe Usage Enabled: ", FALSE)->buildRadioList("recipe", $alchemyRecipe, $alchemySettings->recipe)
->buildComment("Alchemy Cost: ", FALSE)->buildTextField("cost", $alchemySettings->cost)
->buildComment("Alchemy License Item: ", FALSE)->buildTextField("license", $alchemySettings->license)
->buildComment("Usergroup(s) permitted to use alchemy(separate by comma): ", FALSE)->buildTextField("usergroup", ($alchemySettings->usergroup == "all")?$alchemySettings->usergroup:implode(",", $alchemySettings->usergroup))
->buildButton("Change Alchemy Settings", "submit", "submit");
$document->add($settingsForm);
}
}
?>
(alchemyview.php)

<?php

use Resource\Native\String;
use Resource\Collection\ArrayList;

class Alchemy extends Model{
// The item class.

protected $alid;
protected $item;
protected $item2;
protected $item3;
protected $newItem;
protected $chance;
protected $recipe;
protected $validator;
protected $settings;

public function __construct($iid, $iid2, $iid3, AlchemySetting $settings){
$mysidia = Registry::get("mysidia");
$this->item = new PrivateItem($iid);
$this->item2 = new PrivateItem($iid2);
$this->item3 = new PrivateItem($iid3);
$this->settings = $settings;
$this->loadValidator();

$whereClause = "(item = {$this->item->id} and item2 = {$this->item2->id} and item3 = {$this->item3->id}) OR (item = {$this->item2->id} and item2 = {$this->item->id} and item3 = {$this->item3->id})";
$alchemy = $mysidia->db->select("alchemy", array(), $whereClause)->fetchObject();
if(!is_object($alchemy)) throw New ItemException("alchemy_invalid");

$this->alid = $alchemy->alid;
$this->newItem = new StockItem($alchemy->newitem);
$this->chance = $alchemy->chance;
$this->recipe = ($alchemy->recipe and $alchemy->recipe != "none")?new Item($alchemy->recipe):NULL;
$this->usergroup = $alchemy->usergroup;
}

public function getItem(){
return $this->item;
}

public function getItem2(){
return $this->item2;
}

public function getItem3(){
return $this->item3;
}

public function getNewItem(){
return $this->newItem;
}

public function getChance(){
return $this->chance;
}

public function getRecipe(){
return $this->recipe;
}

public function getUsergroup(){
return $this->usergroup;
}

public function mix(){
$this->validator->validate();
$this->consume();
$this->produce();
}

public function consume(){
$this->item->remove();
$this->item2->remove();
$this->item3->remove();
}

public function produce(){
$mysidia = Registry::get("mysidia");
$mysidia->user->changecash(-1*$this->settings->cost);
$this->newItem->append(1, $mysidia->user->username);
}

protected function loadValidator(){
$validations = new ArrayList;
$validations->add(new String("items"));
$validations->add(new String("license"));
$validations->add(new String("cost"));
$validations->add(new String("recipe"));
$validations->add(new String("usergroup"));
$validations->add(new String("chance"));
$this->validator = new AlchemyValidator($this, $this->settings, $validations);
}

protected function save($field, $value){
return FALSE;
}
}
?>
(class_alchemy.php)

<?php

use Resource\Collection\ArrayList;

class AlchemyValidator extends Validator{

private $alchemy;
private $settings;
private $validations;
private $status;

public function __construct(Alchemy $alchemy, AlchemySetting $settings, ArrayList $validations){
$this->alchemy = $alchemy;
$this->settings = $settings;
$this->validations = $validations;
}

public function getValidations(){
return $this->validations;
}

public function setValidations(ArrayList $validations, $overwrite = FALSE){
if($overwrite) $this->validations = $validations;
else{
$iterator = $validations->iterator();
while($iterator->hasNext()){
$this->validations->append($iterator->next());
}
}
}

public function getStatus(){
return $this->status;
}

public function setStatus($status = ""){
$this->status = $status;
}

public function validate(){
$iterator = $this->validations->iterator();
while($iterator->hasNext()){
$validation = $iterator->next();
$method = "check{$validation->capitalize()}";
$this->$method();
}
return TRUE;
}

private function checkItems(){
if(!$this->alchemy->getItem() or !$this->alchemy->getItem2() or !$this->alchemy->getItem3()) throw new ItemException("alchemy_empty");
else{
if($this->alchemy->getItem()->quantity < 1 or $this->alchemy->getItem2()->quantity < 1 or $this->alchemy->getItem3()->quantity < 1){
throw new ItemException("alchemy_insufficient");
}
return TRUE;
}
}

private function checkChance(){
if($this->settings->chance == "disabled") return TRUE;
$chance = $this->alchemy->getChance();
$rand = rand(0, 99);
if($rand < $chance) return TRUE;
else{
$this->alchemy->consume();
throw new ItemException("alchemy_chance");
}
}

private function checkCost(){
if($this->settings->cost == 0) return TRUE;
$mysidia = Registry::get("mysidia");
if($mysidia->user->money >= $this->settings->cost) return TRUE;
else throw new ItemException("alchemy_cost");
}

private function checkLicense(){
if(!$this->settings->license) return TRUE;
$mysidia = Registry::get("mysidia");
$license = new PrivateItem($this->settings->license, $mysidia->user->username);
if($license->quantity >= 1) return TRUE;
else throw new ItemException("alchemy_license");
}

private function checkRecipe(){
if($this->settings->recipe == "disabled" or !$this->alchemy->getRecipe()) return TRUE;
$mysidia = Registry::get("mysidia");
$recipe = new PrivateItem($this->alchemy->getRecipe()->itemname, $mysidia->user->username);
if($recipe->quantity >= 1) return TRUE;
else throw new ItemException("alchemy_recipe");
}

private function checkUsergroup(){
if($this->settings->usergroup == "all") return TRUE;
$mysidia = Registry::get("mysidia");
foreach($this->settings->usergroup as $usergroup){
if($mysidia->user->usergroup->gid == $usergroup) return TRUE;
}
throw new ItemException("alchemy_usergroup");
}
}
?>
(class_alchemyvalidator)

<?php

//Language variables used for AdminCP/Inventory Page

$lang['default_title'] = "Manage Alchemy";
$lang['default'] = "Here is a list of practices that can be used for alchemy<br><br>";
$lang['default_none'] = "Currently there is no alchemy practices possible for your site.";
$lang['nonexist'] = "The item does not exist in your database.";
$lang['add_title'] = "Create new Alchemy Practices";
$lang['add'] = "This page allows you to create a new possible alchemy practices for your users to use.
Please fill in the form below and hit the <i>Create New Alchemy Practice</i> button below when you're ready.<br>";
$lang['added_title'] = "Alchemy Practice Created Successfully";
$lang['added'] = "Successfully created new alchemy practice. You may <a href='../index'>go back to the Admin CP index page</a>.";
$lang['edit_title'] = "Edit Alchemy Practices";
$lang['edit'] = "This page allows you to edit an existing alchemy practice.
Please fill in the form below and hit the <i>Edit Alchemy Practice</i> button below when you're ready.";
$lang['edited_title'] = "Alchemy edited Successfully";
$lang['edited'] = "Successfully modified an existing alchemy practice. You may <a href='../../index'>go back to the Admin CP index page</a>.";
$lang['delete_title'] = "Alchemy Practice Remoced";
$lang['delete'] = "You have successfully deleted this practice from Alchemy Library.";
$lang['settings_title'] = "Changing Alchemy Settings";
$lang['settings'] = "Here you can modify settings for the alchemy system.<br>";
$lang['settings_changed_title'] = "Settings Changed Successfully";
$lang['settings_changed'] = "You have successfully modified the alchemy system settings.";
$lang['item'] = "You did not specify the first ingredient item for alchemy, or that the item entered was invalid.";
$lang['item2'] = "You did not specify the second ingredient item for alchemy, or that the item entered was invalid.";
$lang['item3'] = "You did not specify the third ingredient item for alchemy, or that the item entered was invalid.";
$lang['item2'] = "You did not specify the resulting new item for alchemy, or that the item entered was invalid.";
$lang['duplicate'] = "An alchemy practice with the two ingredient items specified already exists, please go back and edit the fields.";
$lang['chance'] = "The textfield chance must contain an integer between 0 to 100. Please go back and try again.";

$lang['alchemy_title'] = "Welcome to the Alchemy Service";
$lang['alchemy'] = "You come upon a quaint, older building in the middle of the Mysgardia Kingdom. You see various types of mages here, utilizing the workstations to magically craft powerful new items. A few of the Mysgardian Kingdom's forces stand idly by, keeping watch and discouraging anyone from stealing.<br /><br />";
$lang['alchemy_choose'] = " You select your first item:";
$lang['alchemy_choose2'] = "Then you select your second:";
$lang['alchemy_choose3'] = "Then you select your third:";
$lang['alchemy_disabled'] = "Unfortunately the admin has disabled the Alchemy System for this site, you may send him/her a message for more information.<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_success'] = "Congratulations!";
$lang['alchemy_newitem'] = "You have successfully produced a new item ";
$lang['alchemy_newitem2'] = " by using Alchemy. You may now manage it in your inventory, or continue to use the alchemy system.<br /><br />
<a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_invalid'] = "The specified item combination is invalid, it does not produce a new item...<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_empty'] = "You have not entered three valid items for performing alchemy.<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_insufficient'] = "You do not have the necessary items for producing a new item through alchemy.<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_chance'] = "The alchemy fails! How unfortunate, maybe you should try again?<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_cost'] = "Apparently you do not have enough money to afford the alchemy service, please come back later.<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_license'] = "You appear to lack the license required to perform alchemy, please make sure you have the license in your inventory first.<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_recipe'] = "It seems that you do not have the recipe to produce an item from the two selected items.<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_usergroup'] = "Unfortunately, the admin has specified that only certain users can perform alchemy, you may consult him/her by sending a message.<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
?>
(lang_alchemy.php)

<?php

class InventoryController extends AppController{

const PARAM = "confirm";

public function __construct(){
parent::__construct("member");
}

public function index(){
$mysidia = Registry::get("mysidia");
$inventory = new Inventory($mysidia->user);
if($inventory->gettotal() == 0) throw new InvalidIDException("inventory_empty");
$this->setField("inventory", $inventory);
}

public function uses(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new ItemException("use_none");

if($mysidia->input->post("aid")){
if(!$item->checktarget($mysidia->input->post("aid")) or $mysidia->input->post("validation") != "valid"){
throw new ItemException("use_fail");
}
elseif(!$item->randomchance()){
$item->remove();
throw new ItemException("use_effect");
}
else{
$message = $item->apply($mysidia->input->post("aid"));
$this->setField("message", $message);
}
return;
}

$stmt = $mysidia->db->select("owned_adoptables", array("aid", "name"), "owner = '{$mysidia->user->username}'");
$map = $mysidia->db->fetchMap($stmt);
$this->setField("petMap", $map);
}

public function sell(){
$mysidia = Registry::get("mysidia");
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new ItemException("sell_none");

if(!$mysidia->input->post("quantity")) throw new ItemException("sell_empty");
elseif($item->quantity < $mysidia->input->post("quantity")) throw new ItemException("sell_quantity");
else $item->sell($mysidia->input->post("quantity"));
}

public function toss(){
$mysidia = Registry::get("mysidia");
$item = new PrivateItem($mysidia->input->post("itemname"), $mysidia->user->username);
if($item->iid == 0) throw new ItemException("toss_none");
if($mysidia->input->get("confirm")){
$item->toss();
return;
}
}

public function alchemy(){
$mysidia = Registry::get("mysidia");
$settings = new AlchemySetting($mysidia->db);
if($settings->system == "disabled") throw new ItemException("alchemy_disabled");

if($mysidia->input->post("iid") and $mysidia->input->post("iid2") and $mysidia->input->post("iid3")){
$alchemy = new Alchemy($mysidia->input->post("iid"), $mysidia->input->post("iid2"), $mysidia->input->post("iid3"), $settings);
$alchemy->mix();
$this->setField("alchemy", $alchemy);
return;
}

$stmt = $mysidia->db->select("inventory", array("iid", "itemname"), "owner = '{$mysidia->user->username}'");
$map = $mysidia->db->fetchMap($stmt);
$this->setField("itemMap", $map);
$this->setField("settings", $settings);
}
}
?>
(inventory.php)

<?php

use Resource\Collection\LinkedList;

class InventoryView extends View{

public function index(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle($mysidia->lang->inventory);
$document->addLangvar("You may manage these items as you like, or go to the alchemy page to make your own items: <br>");
$document->add(new Link("inventory/alchemy", "Use the Alchemy Service Now!"));
$document->add(new Comment("<br><br>"));
$inventory = $this->getField("inventory");
$inventoryTable = new TableBuilder("inventory");
$inventoryTable->setAlign(new Align("center", "middle"));
$inventoryTable->buildHeaders("Image", "Category", "Name", "Description", "Quantity", "Use", "Sell", "Toss");
$inventoryTable->setHelper(new ItemTableHelper);

$iids = $inventory->getiids();
for($i = 0; $i < $iids->length(); $i++){
$item = $inventory->getitem($iids[$i]);
$cells = new LinkedList;
$cells->add(new TCell($inventory->getitemimage($item->imageurl)));
$cells->add(new TCell($item->category));
$cells->add(new TCell($item->itemname));
$cells->add(new TCell($item->description));
$cells->add(new TCell($item->quantity));
$cells->add(new TCell($inventoryTable->getHelper()->getUseForm($item)));
$cells->add(new TCell($inventoryTable->getHelper()->getSellForm($item)));
$cells->add(new TCell($inventoryTable->getHelper()->getTossForm($item)));
$inventoryTable->buildRow($cells);
}
$document->add($inventoryTable);
}

public function uses(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
if($mysidia->input->post("aid")){
$message = (string)$this->getField("message");
$document->setTitle($mysidia->lang->global_action_complete);
$document->addLangvar($message);
return;
}

$petMap = $this->getField("petMap");
$document->setTitle($mysidia->lang->select_title);
$document->addLangvar($mysidia->lang->select);
$chooseFrom = new Form("chooseform", "uses", "post");

$adoptable = new DropdownList("aid");
$adoptable->add(new Option("None Selected", "none"));
if($petMap->size() > 0){
$iterator = $petMap->iterator();
while($iterator->hasNext()){
$adopt = $iterator->nextEntry();
$adoptable->add(new Option($adopt->getValue(), $adopt->getKey()));
}
}
$chooseFrom->add($adoptable);

$chooseFrom->add(new PasswordField("hidden", "itemname", $mysidia->input->post("itemname")));
$chooseFrom->add(new PasswordField("hidden", "validation", "valid"));
$chooseFrom->add(new Button("Choose this Adopt", "submit", "submit"));
$document->add($chooseFrom);
}

public function sell(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle($this->lang->global_transaction_complete);
$document->addLangvar("{$this->lang->sell}");
}

public function toss(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
if($mysidia->input->get("confirm")){
$document->setTitle($this->lang->global_action_complete);
$document->addLangvar("{$this->lang->toss}{$mysidia->input->post("itemname")}{$this->lang->toss2}");
return;
}

$document->setTitle($this->lang->toss_confirm);
$document->addLangvar($this->lang->toss_warning);

$confirmForm = new FormBuilder("confirmform", "toss/confirm", "post");
$confirmForm->buildPasswordField("hidden", "action", "toss")
->buildPasswordField("hidden", "itemname", $mysidia->input->post("itemname"))
->buildButton("Please Toss", "confirm", "confirm");
$document->add($confirmForm);
}

public function alchemy(){
$mysidia = Registry::get("mysidia");
$document = $this->document;

if($mysidia->input->post("iid") and $mysidia->input->post("iid2") and $mysidia->input->post("iid3")){
$alchemy = $this->getField("alchemy");
$newitem = $alchemy->getNewItem()->itemname;
$document->setTitle($this->lang->alchemy_success);
$document->addLangvar($this->lang->alchemy_newitem.$newitem.$this->lang->alchemy_newitem2);
return;
}

$document->setTitle($this->lang->alchemy_title);
$document->addLangvar($this->lang->alchemy);
$itemMap = $this->getField("itemMap");
$settings = $this->getField("settings");
$alchemyFrom = new Form("alchemyform", "alchemy", "post");
$alchemyFrom->add(new Comment("<b>Cost of performing Alchemy: {$settings->cost} {$mysidia->settings->cost}</b><br>"));

$alchemyFrom->add(new Comment($mysidia->lang->alchemy_choose));
$items = new DropdownList("iid");
$items->add(new Option("None Selected", "none"));
if($itemMap->size() > 0){
$iterator = $itemMap->iterator();
while($iterator->hasNext()){
$item = $iterator->nextEntry();
$items->add(new Option($item->getValue(), $item->getKey()));
}
}
$alchemyFrom->add($items);

$alchemyFrom->add(new Comment($mysidia->lang->alchemy_choose2));
$items2 = new DropdownList("iid2");
$items2->add(new Option("None Selected", "none"));
if($itemMap->size() > 0){
$iterator = $itemMap->iterator();
while($iterator->hasNext()){
$item2 = $iterator->nextEntry();
$items2->add(new Option($item2->getValue(), $item2->getKey()));
}
}
$alchemyFrom->add($items2);

$alchemyFrom->add(new Comment($mysidia->lang->alchemy_choose3));
$items3 = new DropdownList("iid3");
$items3->add(new Option("None Selected", "none"));
if($itemMap->size() > 0){
$iterator = $itemMap->iterator();
while($iterator->hasNext()){
$item3 = $iterator->nextEntry();
$items3->add(new Option($item3->getValue(), $item3->getKey()));
}
}
$alchemyFrom->add($items3);

$alchemyFrom->add(new Button("Let's mix the items now!", "submit", "submit"));
$document->add($alchemyFrom);
}
}
?>
(inventoryview.php)

<?php

//Language variables used for Inventory Page

$lang['inventory'] = "Here is the list of every item you own";
$lang['inventory_empty'] = "You currently do not have any items in inventory.";
$lang['select_title'] = "Select an adoptable";
$lang['select'] = "Now you need to choose an adoptable to use this item:<br>";
$lang['item_error'] = "An error has occurred while manipulating item";
$lang['use_none'] = "It appears that you do not have this item in your inventory.";
$lang['use_fail'] = "It seems that item can not be used on the adoptable selected.";
$lang['use_effect'] = "The item refuses to take effect, what a waste of money and effort!";
$lang['sell_empty'] = "You have yet to specify the quantity of items to sell...<br>";
$lang['sell_none'] = "It appears that you do not have this item in your inventory.";
$lang['sell_quantity'] = "It seems that you wish to sell more items than you already own, this action is invalid.<br>";
$lang['sell'] = "You have sold ";
$lang['sell2'] = "successfully and earned some money back.{$mysidia->input->post("cost")}<br>";
$lang['toss_confirm'] = "Confirm your Action";
$lang['toss_warning'] = "Are you sure you wish to toss {$mysidia->input->post("itemname")}?<br>
It will be permanently removed from your inventory, and this action cannot be undone!<br>";
$lang['toss_none'] = "It appears that you do not have this item in your inventory.";
$lang['toss'] = "You have successfully removed ";
$lang['toss2'] = " from your inventory.";

$lang['alchemy_title'] = "Welcome to the Alchemy Service";
$lang['alchemy'] = "stuff goes here.<br /><br />";
$lang['alchemy_choose'] = " You select your first item:";
$lang['alchemy_choose2'] = "Then you select your second:";
$lang['alchemy_choose3'] = "Then you select your third:";
$lang['alchemy_disabled'] = "Unfortunately the admin has disabled the Alchemy System for this site, you may send him/her a message for more information.<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_success'] = "Congratulations!";
$lang['alchemy_newitem'] = "You have successfully produced a new item ";
$lang['alchemy_newitem2'] = " by using Alchemy. You may now manage it in your inventory, or continue to use the alchemy system.<br /><br />
<a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_invalid'] = "The specified item combination is invalid, it does not produce a new item...<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_empty'] = "You have not entered two valid items for performing alchemy.<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_insufficient'] = "You do not have the necessary items for producing a new item through alchemy.<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_chance'] = "The alchemy fails! How unfortunate, maybe you should try again?<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_cost'] = "Apparently you do not have enough money to afford the alchemy service, please come back later.<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_license'] = "You appear to lack the license required to perform alchemy, please make sure you have the license in your inventory first.<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_recipe'] = "It seems that you do not have the recipe to produce an item from the two selected items.<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
$lang['alchemy_usergroup'] = "Unfortunately, the admin has specified that only certain users can perform alchemy, you may consult him/her by sending a message.<br /><br /> <a href='/inventory/alchemy'><button type='button'>Return</button></a>";
?>
(lang_inventory.php)

Corsair
11-30-2016, 05:45 AM
Thank you Dinocanid for some reason I missed your comment.