Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.io.*;
- import java.nio.file.Paths;
- import java.util.regex.*;
- import java.awt.*;
- import java.awt.event.MouseAdapter;
- import static javax.swing.JOptionPane.*;
- PFont f;
- //
- Material[] material = new Material[21];//all of the materials available. exact number
- Material[] metal = new Material[material.length];
- Material[] precious = new Material[material.length];
- Material[] wood = new Material[material.length];
- Material[] cloth = new Material[material.length];
- String metalsList, preciousList, woodList, clothList;
- //PImage backGround = null;
- void setup()
- {
- f = createFont("Arial",16,true);
- //backGround = loadImage("background.jpg"); // image of a small logo logo
- }
- void settings()
- {
- size(360,100);
- }
- void draw()
- {
- background(255,255,255); // white
- //image(backGround, 0,0);
- stroke(175);
- textFont(f); // using the font that was defined at setup
- fill(0,0,0); // Black fill color for text
- textAlign(LEFT); // text - left to right
- text("Sell Item",40,60);
- text("Find Value",150,60);
- text("Crafting",260,60);
- fill(255,0,0);
- text("3.8 Tools",80,20);
- }
- void mousePressed()
- {
- if( mouseX >= 40 && mouseX <= 120 && mouseY >= 50 && mouseY <= 70)
- {
- sellItem();
- }
- else if( mouseX >= 150 && mouseX <= 200 && mouseY >= 50 && mouseY <= 70)
- {
- goldValue();
- }
- else if( mouseX >= 260 && mouseX <= 310 && mouseY >= 50 && mouseY <= 70)
- {
- craft();
- }
- }
- void sellItem()
- {
- String val = showInputDialog("Insert the value of the item");
- int itemWorth = parseInt(val);
- int rarity; if(itemWorth > 1000) rarity = 20 + (itemWorth-1000)/200; else rarity = itemWorth/50;
- val = showInputDialog("Pricing: Roll Appraise or Profession(Merchant) and write down the score");
- int barterScore = parseInt(val);
- val = showInputDialog("Where are you trying to sell the item?(Type 1/2/3)\n"
- + "1 - City\n"
- + "2 - Town\n"
- + "3 - Village\n");
- rarity += (parseInt(val)*5);
- val = showInputDialog("Rarity: How common is this item for such a market(DM discretion)?\n"
- + "1 - Common \n"
- + "2 - Odd \n"
- + "3 - Rare \n");
- rarity += (parseInt(val)-1)*5;
- barterScore += (parseInt(val)-1)*4;
- val = showInputDialog("Finding Buyers: Roll Gather Information or Profession(Merchant) and write down the score");
- int gatherScore = parseInt(val);
- int finalPrice = 0; //percentage
- if(barterScore <=10) finalPrice = ((barterScore*5)*itemWorth)/100;
- else if (barterScore <60) finalPrice = ((50+((barterScore-10)*1))*itemWorth)/100;
- else finalPrice = itemWorth;
- String description = "";
- boolean failure = false;
- if(gatherScore > rarity) description = "After a few moments you find a buyer";
- else if(gatherScore > rarity-10) description = "You wait for a couple of hours until you find a buyer";
- else if(gatherScore > rarity-20) description = "It takes almost the entire day, but by the end of it you find a buyer";
- else
- {
- description = "You have failed to find any buyers for your item";
- showMessageDialog(null,""+description+"","Failure", ERROR_MESSAGE);
- failure = true;
- }
- if(failure == false)
- showMessageDialog(null,""+description+"\n "+"The Item was sold for "+finalPrice+"g","Failure", WARNING_MESSAGE);
- }
- void goldValue()
- {
- int mul =1; // multiplier
- int base = 200; // every X
- String val = showInputDialog("Insert 3.5 Item value");
- int value = parseInt(val);
- boolean calc = true;
- int finalVal = 0;
- while( calc == true)
- {
- if(value > 0)
- {
- value = value-base; //600, 180
- if(value > 0)
- finalVal = finalVal + (base/mul); //410
- else
- finalVal = finalVal + ((base+value)/mul); // "value" is negative at this stage
- base += ((base*10)/100) + 400;
- mul++;
- println("= "+finalVal);
- }
- else{
- calc = false;
- println(" = "+finalVal);
- }
- }
- showMessageDialog(null, " "+val+"g(V3.5) = "+finalVal+"g(V3.8) \n","Gold Worth" , WARNING_MESSAGE);
- println("FINAL = "+finalVal);
- }
- void craft()
- {
- // base concept: Craft = Value of materials + value of enchantment + DC to create.
- initMaterials();
- String val = showInputDialog("\n 1) Weaponsmith \n 2) Jewelery \n 3) Armorsmith \n 4) Tailor \n 5) Woodcraft \n 6) Enchant \n 7) alchemy");
- int craftType = parseInt(val);
- switch(craftType)
- {
- case 1:
- weaponSmith();
- break;
- case 2:
- val = showInputDialog("1) Craft jewels \n 2) Decorate items");
- int jewelType = parseInt(val);
- if(jewelType==1) jewelery();
- else decorate();
- break;
- case 3:
- armorSmith();
- break;
- case 4:
- val = showInputDialog("1) Sew common clothing \n 2) Armor tailor");
- int tailorType = parseInt(val);
- if(tailorType==1) clothTailor();
- else
- {
- Material leather = new Material();
- val = showInputDialog("What is the cloth made of? (For example 'fabric' or 'Lion' or 'Dragon')");
- leather.name = val;
- val = showInputDialog("Type the CR of the creature if the cloth is made of magical beast (unicorn, hydra, etc) \n type 0 if it isn't a magical beast");
- leather.dc = parseInt(val);
- leather.value = 5+leather.dc*10;
- leather.magic = 2+(leather.dc/4);
- armorTailor(leather);
- }
- break;
- case 5:
- craftWood();
- break;
- case 6:
- enchant();
- break;
- case 7:
- alchemy();
- break;
- }
- }
- Material initMaterials()
- {
- for(int i=0; i<material.length; i++) material[i]= new Material();
- material[0].fabric(); material[1].silk(); material[3].dragonHide(); material[4].monsterHide(); material[5].copper();
- material[6].iron(); material[7].steel(); material[8].dragonBone(); material[9].demonicMetal(); material[10].silver();
- material[11].alchemicalSilver(); material[12].gold(); material[13].elvenSteel(); material[14].dwarvenSteel(); material[15].rageGlass();
- material[16].adamantium(); material[17].yew(); material[18].darkWood(); material[19].sapWood(); material[20].coreWood();
- Material choice = null;
- //metals
- int x = 0;
- for(int i=0; i<metal.length; i++){
- if(material[i]!=null && material[i].metal==true){metal[x]=material[i]; println(metal[x].name); x++; }
- }
- metalsList = "";
- for(int i=0; i<metal.length; i++)
- {
- if(metal[i]!=null){
- metalsList +=(i+1)+") "+metal[i].name+"(DC"+metal[i].dc+")\n";
- }
- }
- // precious
- x = 0;
- for(int i=0; i<precious.length; i++){
- if(material[i]!=null && material[i].precious==true){precious[x]=material[i]; x++; }
- }
- preciousList = "";
- for(int i=0; i<precious.length; i++)
- {
- if(precious[i]!=null){
- preciousList +=(i+1)+") "+precious[i].name+"(DC"+precious[i].dc+")\n";
- }
- }
- // cloth
- x = 0;
- for(int i=0; i<cloth.length; i++){
- if(material[i]!=null && material[i].cloth==true){cloth[x]=material[i]; x++; }
- }
- clothList = "";
- for(int i=0; i<cloth.length; i++)
- {
- if(cloth[i]!=null){
- clothList +=(i+1)+") "+cloth[i].name+"(DC"+cloth[i].dc+")\n";
- }
- }
- // wood
- x = 0;
- for(int i=0; i<wood.length; i++){
- if(material[i]!=null && material[i].wood==true){wood[x]=material[i]; x++; }
- }
- woodList = "";
- for(int i=0; i<wood.length; i++)
- {
- if(wood[i]!=null){
- woodList +=(i+1)+") "+wood[i].name+"(DC"+wood[i].dc+")\n";
- }
- }
- return choice;
- }
- void weaponSmith()
- {
- String val = showInputDialog("Choose a material for your craft(type down a number) \n"+metalsList);
- Material m = metal[parseInt(val)-1];
- //println(" = "+m.name);
- Item[] item = new Item[20]; for(int i=0; i<item.length; i++) item[i]= new Item();
- item[0].shortSword(); item[1].longSword(); item[2].morningStar(); item[3].flail(); item[4].heavyFlail();item[5].lightHammer();
- item[6].warHammer(); item[7].orcishAxe(); item[8].handAxe(); item[9].greatAxe(); item[10].spikedChain();
- item[11].dagger(); item[12].greatSword(); item[13].bastardSword(); item[14].dagger(); item[15].scimitar();
- item[16].arrowHead(); item[17].spearHead();
- finalCraft(item, m);
- }
- void armorSmith()
- {
- String val = showInputDialog("Choose a material for your craft(type down a number) \n"+metalsList);
- Material m = metal[parseInt(val)-1];
- //println(" = "+m.name);
- Item[] item = new Item[20]; for(int i=0; i<item.length; i++) item[i]= new Item();
- item[0].chainShirt(); item[1].chainMail(); item[2].scaleMail(); item[3].splintMail(); item[4].breastPlate();item[5].bandedMail();
- item[6].halfPlate(); item[7].fullPlate(); item[8].armorBoots(); item[9].gauntlet(); item[10].lightShield();
- item[11].heavyShield(); item[12].towerShield();
- finalCraft(item, m);
- }
- void clothTailor()
- {
- String val = showInputDialog("Choose a material for your craft(type down a number) \n"+clothList);
- Material m = cloth[parseInt(val)-1];
- //println(" = "+m.name);
- Item[] item = new Item[20]; for(int i=0; i<item.length; i++) item[i]= new Item();
- item[0].robe(); item[1].cloak(); item[2].boots(); item[3].gloves(); item[4].belt();
- finalCraft(item, m);
- }
- void armorTailor(Material m)
- {
- //println(" = "+m.name);
- Item[] item = new Item[20]; for(int i=0; i<item.length; i++) item[i]= new Item();
- item[0].paddedArmor(); item[1].leatherArmor(); item[2].studdedArmor(); item[3].hideArmor();
- finalCraft(item, m);
- }
- void jewelery()
- {
- String val = showInputDialog("Choose a material for your craft(type down a number) \n"+preciousList);
- Material m = precious[parseInt(val)-1];
- //println(" = "+m.name);
- Item[] item = new Item[20]; for(int i=0; i<item.length; i++) item[i]= new Item();
- item[0].earring(); item[1].ring(); item[2].necklace();
- finalCraft(item, m);
- }
- void decorate()
- {
- String val = showInputDialog("Write down the magical capacity of the item you are decorating \n");
- int cap = parseInt(val);
- val = showInputDialog("Write down the gold value of the gemstones you use for decoration \n");
- int decor = parseInt(val);
- //if(decor > 100) decor = 100 + ((decor-100)/2);
- val = showInputDialog("Roll Craft(Jewelery) and write down the result \n");
- int score = parseInt(val);
- if(score > 20) score = 20+((score-20)/2);
- int dc = 50;// 50 gold is base dc for +1, increases with capacity.
- int rounder=0;
- for(int i=1; i<cap; i++) {dc = dc*3; dc = (dc/3)+dc/i; rounder=dc%50; dc = dc-rounder;}
- int value = ((decor)*score)/10;
- String describe = "";
- if(value >= dc) describe = "The magical capacity of the item increases by +1(passed "+dc+" value)";
- else describe = "Magical capacity has not changed(Requires "+dc+" Value)";
- String description= "Takes "+((1)+(decor/50))+" hours of work \n "
- + describe+" \n"
- + "Added gold value of "+value+" to the item";
- showMessageDialog(null,""+description,"Crafting", WARNING_MESSAGE);
- }
- void craftWood()
- {
- String val = showInputDialog("Choose a material for your craft(type down a number) \n"+woodList);
- Material m = wood[parseInt(val)-1];
- //println(" = "+m.name);
- Item[] item = new Item[20]; for(int i=0; i<item.length; i++) item[i]= new Item();
- item[0].shortBow(); item[1].longBow(); item[2].greatBow(); item[3].heavyCrossbow(); item[4].lightCrossbow(); item[5].handCrossbow();
- item[6].heavyRepeater(); item[7].lightRepeater(); item[8].greatCrossbow(); item[9].shortSpearShaft(); item[10].longSpearShaft();
- item[11].arrowShaft(); item[12].boltShaft(); item[13].wagon(); item[14].shelter(); item[15].barricade();
- finalCraft(item, m);
- }
- void enchant()
- {
- String val = showInputDialog("Write down the level of enchantment \n");
- int bonus = parseInt(val);
- int value = 100; //+1
- int rounder = 0;
- int dc = 10+(bonus*5);
- for(int i=1; i<bonus; i++) {value = value*3; value = (value/3)+value/i; rounder=value%100; value = value-rounder;}
- String description= "Takes "+((4)+(dc/10))+" hours of work \n "
- + dc+" DC \n"
- + "+"+bonus+" Enchantment \n"
- + "Value = "+value;
- showMessageDialog(null,""+description,"Crafting", WARNING_MESSAGE);
- }
- void alchemy()
- {
- String val = showInputDialog("Write down the level of ingredients \n");
- int bonus = parseInt(val);
- int value = 12; //+1
- int rounder = 0;
- int dc = 10+(bonus*5);
- for(int i=1; i<bonus; i++) {value = value*3; value = (value/3)+value/i; rounder=value%10; value = value-rounder;}
- String description= "Takes "+((1)+(dc/10))+" hours of work \n "
- + dc+" DC \n"
- + " 1d4 potions created(Roll) \n"
- + "+"+bonus+" Potion \n"
- + "Value = "+value+" (per potion)";
- showMessageDialog(null,""+description,"Crafting", WARNING_MESSAGE);
- }
- int getFinalValue(int _bv, int _dc)
- {
- int value = 0;
- // base value = bv, dc = difficulty challenge
- if(_dc > 20) _dc = 20 + ((_dc-20)/2);
- value = (_bv*_dc)/10;
- return value;
- }
- void finalCraft(Item[] item, Material m)
- { // works similiar to most crafts
- Item choice = null;
- String itemList="";
- for(int i=0; i<item.length; i++)
- {
- if(item[i].name!=null)
- {
- itemList +=(i+1)+") "+item[i].name+"(DC"+item[i].dc+") \n";
- }
- }
- String val = showInputDialog("Choose the item you wish to create \n"+itemList);
- choice = item[parseInt(val)-1]; println(" = "+choice.name);
- val = showInputDialog("Roll the relevant craft skill and write down your score");
- int score = parseInt(val);
- int dc = m.dc+choice.dc+10;
- if(score < dc)
- {
- showMessageDialog(null,"Failure! item requires "+dc+"DC to craft","Failure", ERROR_MESSAGE);
- }
- else{
- int baseValue = (m.value*choice.mass);
- int value = getFinalValue(baseValue, dc);
- String description= "Takes "+((choice.mass*2)+(dc/10))+" hours of work \n "
- + m.name+" "+choice.name+"\n"
- + dc+" DC \n"
- + choice.mass+" Materials("+m.name+")\n"
- + "Value = "+value;
- showMessageDialog(null,""+description,"Crafting", WARNING_MESSAGE);
- }
- }
- class Enchantment
- {
- int bonus; // ench bonus
- int value = 100; //+1
- void updateValue()
- {
- for(int i=1; i<bonus; i++) {value = value*2; value = (value/2)+value/i; }
- }
- }
- class Material
- {
- boolean metal=false; // qualifies for weapon
- boolean wood=false; // wood type
- boolean precious=false; // qualifies for jewels
- boolean cloth=false;
- int value = 0;
- int dc = 0;
- int magic = 0;
- String name;
- void fabric(){ cloth = true; value = 5; name="Fabric"; }
- void silk(){cloth = true; value = 50; dc=8; name="Silk"; }
- void monsterHide(){cloth = true;/* NEEDS TO ADD TEMPLATE FOR CREATION*/ value = 50; name="MonsterHide"; }
- void dragonHide(){cloth = true; value = 400; dc=20; name="Dragonhide"; }
- void iron(){metal = true; value = 6; dc=0; name="Iron"; }
- void steel(){metal = true; value = 50; dc=5; name="Steel"; }
- void dragonBone(){metal = true; value = 600; dc=20; name="Dragonbone"; }
- void demonicMetal(){metal = true; value = 800; dc=25; name="Demonic-Metal"; }
- void alchemicalSilver(){metal = true; value = 150; dc=10; name="Alchemical-Silver"; }
- void elvenSteel(){metal = true; value = 300; dc=15; name="Elvensteel"; }
- void dwarvenSteel(){metal = true; value = 200; dc=15; name="Dwarvensteel"; }
- void rageGlass(){metal = true; value = 50; dc=30; name="Rage-glass"; }
- void adamantium(){metal = true; value = 300; dc=10; name="Adamantium"; }
- void copper(){metal = true; precious = true; value = 5; dc=0; name="Copper"; }
- void silver(){ precious = true; value = 100; dc=5; name="Silver"; }
- void gold(){ precious = true; value = 800; dc=10; name="Gold"; }
- void yew(){ wood = true; value = 5; dc=0; name="Yew-wood"; }
- void sapWood(){ wood = true; value = 100; dc=5; name="Sapwood"; }
- void darkWood(){ wood = true; value = 150; dc=12; name="Darkwood"; }
- void coreWood(){ wood = true; value = 600; dc=20; name="Corewood"; }
- }
- class Item
- {
- int dc = 0;
- int mass =1; // how much material to craft
- String name;
- void flail(){ dc=0; name="Flail(Light)"; mass=2; }
- void heavyFlail(){ dc=0; name="Flail(Heavy)"; mass=3; }
- void morningStar(){ dc=2; name="Morningstar"; mass=2; }
- void lightHammer(){ dc=0; name="Hammer(Light)"; mass=2; }
- void warHammer(){ dc=0; name="War-Hammer"; mass=3; }
- void handAxe(){ dc=5; name="Handaxe"; mass=2; }
- void greatAxe(){ dc=5; name="Greataxe"; mass=4; }
- void orcishAxe(){ dc=15; name="Orcishaxe"; mass=4; }
- void shortSword(){ dc=3; name="Shortsword"; mass=2; }
- void longSword(){ dc=5; name="Longsword"; mass=3; }
- void greatSword(){ dc=5; name="Greatsword"; mass=4; }
- void bastardSword(){ dc=10; name="Bastardsword"; mass=3; }
- void dagger(){ dc=4; name="Dagger"; mass=1; }
- void spikedChain(){ dc=10; name="Spiked-Chain"; mass=3; }
- void scimitar(){ dc=10; name="Scimitar"; mass=2; }
- void spearHead(){ dc=0; name="Spearhead"; mass=1; }
- void arrowHead(){ dc=3; name="x30 Arrow/Bolt heads"; mass=1; }
- void shortBow(){ dc=3; name="Shortbow"; mass=2; }
- void longBow(){ dc=5; name="Longbow"; mass=3; }
- void greatBow(){ dc=7; name="Greatbow"; mass=4; }
- void handCrossbow(){ dc=15; name="Hand-Crossbow"; mass=3; }
- void lightCrossbow(){ dc=8; name="Crossbow(Light)"; mass=3; }
- void heavyCrossbow(){ dc=10; name="Crossbow(Heavy)"; mass=4; }
- void greatCrossbow(){ dc=12; name="Crossbow(Great)"; mass=5; }
- void heavyRepeater(){ dc=15; name="Repeating Crossbow(Heavy)"; mass=3; }
- void lightRepeater(){ dc=13; name="Repeating Crossbow(Light)"; mass=4; }
- void shortSpearShaft(){ dc=0; name="Short Spear Shaft"; mass=1; }
- void longSpearShaft(){ dc=0; name="Long Spear Shaft"; mass=2; }
- void arrowShaft(){ dc=5; name="x30 Arrow Shaft"; mass=1; }
- void boltShaft(){ dc=2; name="x30 Bolt Shaft"; mass=1; }
- void cart(){ dc=3; name="Cart(Small)"; mass=15; }
- void wagon(){ dc=3; name="Wagon(Large)"; mass=25; }
- void barricade(){ dc=0; name="Carried Barricade(5x5)"; mass=6; }
- void hut(){ dc=5; name="Wooden hut(30x30)"; mass=40; }
- void shelter(){ dc=3; name="Wooden shelter(40x40)"; mass=20; }
- void house(){ dc=5; name="Wooden House"; mass=100; }
- void chainShirt(){ dc=8; name="Chain Shirt"; mass=4; }
- void scaleMail(){ dc=3; name="Scale Mail"; mass=5; }
- void chainMail(){ dc=8; name="Chain Mail"; mass=6; }
- void breastPlate(){ dc=5; name="Breastplate"; mass=6; }
- void splintMail(){ dc=0; name="Splint Mail"; mass=7; }
- void bandedMail(){ dc=2; name="Banded Mail"; mass=6; }
- void halfPlate(){ dc=10; name="Half-Plate Armor"; mass=9; }
- void fullPlate(){ dc=15; name="Full-Plate Armor"; mass=10; }
- void gauntlet(){ dc=12; name="Gauntlets"; mass=2; }
- void helmet(){ dc=12; name="Gauntlets"; mass=2; }
- void armorBoots(){ dc=5; name="Armored-Boots"; mass=3; }
- void lightShield(){ dc=3; name="Shield(Light)"; mass=2; }
- void heavyShield(){ dc=3; name="Shield(Heavy)"; mass=3; }
- void towerShield(){ dc=8; name="Towershield"; mass=4; }
- void earring(){ dc=2; name="Earring"; mass=1; }
- void ring(){ dc=5; name="Ring"; mass=1; }
- void trinket(){ dc=8; name="Trinket"; mass=1; }
- void necklace(){ dc=5; name="Necklace"; mass=1; }
- void tiara(){ dc=7; name="Tiara"; mass=1; }
- void crown(){ dc=15; name="Crown"; mass=1; }
- void gloves(){ dc=2; name="Gloves"; mass=1; }
- void boots(){ dc=5; name="Boots"; mass=1; }
- void belt(){ dc=3; name="Belt"; mass=1; }
- void cloak(){ dc=1; name="Cloak"; mass=1; }
- void robe(){ dc=8; name="Robe"; mass=3; }
- void paddedArmor(){ dc=0; name="Padded Armor"; mass=3; }
- void leatherArmor(){ dc=2; name="Leather Armor"; mass=4; }
- void studdedArmor(){ dc=7; name="Studded Armor"; mass=4; }
- void hideArmor(){ dc=4; name="Hide Armor"; mass=4; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement