Post by Hauskaz on Mar 19, 2008 18:01:21 GMT -5
// Malaska - The XF Administrative Toolkit
// Account Value Automation (AVA)
// 0.4.0 BETA
// 2008-04-05 Hauskaz
import java.awt.*;
import java.util.Date;
import hsa.Console;
import java.text.DecimalFormat;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.Toolkit;
import java.io.*;
public class Malaska_ValueSystem implements ClipboardOwner
{
static Console c = new Console(30,50);
static double xfPosts, xfAge, xfValueOld, xfValueNew, xfChange, xfVPP; // initialize XF stat variables
static double accountPosts, accountAge, accountVC, accountValueOld = 0, accountValueNew, accountChange = 0, accountROC = 0, accountVPP;
static char confirm;
static String accountName;
static DecimalFormat wholecommas = new DecimalFormat("#,###,##0");
static DecimalFormat decimalcommas = new DecimalFormat("#,###,##0.00");
static TextTransfer ubbc = new TextTransfer();
public static void main(String[] aArguments)
{
c.println("Malaska - The XF Administrative Toolkit"); // Header stuff
c.println("Account Value Automation (AVA)");
c.println("0.4.0 BETA");
c.println("2008-04-05 Hauskaz");
c.println();
c.println("XF statistics are required for further operation.");
while (true) // XF initiation
{
c.print("XF post count: ");
xfPosts = c.readDouble();
c.print("XF age: ");
xfAge = c.readDouble();
c.print("Old value of XF: ");
xfValueOld = c.readDouble();
malaskaValue(true); // Fire off some XF numbers from malaskaValue
c.println();
c.println("XF");
c.print("Posts: ");
c.println((int) xfPosts, 15);
c.print("Age: ");
c.println((int) xfAge, 15);
c.print("Value: ");
c.println(xfValueNew, 15, 2);
c.print("Change: ");
c.println(xfChange, 15, 2);
c.print("Value Per Post:");
c.println(xfVPP, 15,2);
c.println();
copyToClipboard(true);
c.println("Initiation complete.");
c.print("Are these correct values? (y/n): ");
confirm = c.getChar();
c.println(confirm);
if (confirm == 'y' || confirm == 'Y')
break;
}
c.println();
c.println();
while (true) // Account value loop
{
c.println("Enter an account to assess (enter twice quits)");
c.print(">: ");
accountName = c.readLine();
if (accountName.equals(""))
break;
c.print("Is this a new account? (y/n): ");
confirm = c.getChar();
c.println(confirm);
c.print("Account post count: ");
accountPosts = c.readDouble();
c.print("Account age: ");
accountAge = c.readDouble();
c.print("Account value coefficient: ");
accountVC = c.readDouble();
if (confirm == 'n' || confirm == 'N')
{
c.print("Old value of " + accountName + ": ");
accountValueOld = c.readDouble();
}
malaskaValue(false);
c.println();
c.println(accountName);
c.print("Posts: ");
c.println((int) accountPosts, 15);
c.print("Age: ");
c.println((int) accountAge, 15);
c.print("VC: ");
c.println(accountVC, 15, 2);
c.print("Value: ");
c.println(accountValueNew, 15, 2);
if (confirm == 'n' || confirm == 'N')
{
c.print("Change: ");
c.println(accountChange, 15, 2);
c.print("Rate of Change:");
c.println(accountROC, 15, 2);
}
c.print("value Per Post:");
c.println(accountVPP, 15, 2);
c.println();
copyToClipboard(false);
c.println("Account assessed. Press any key to continue.");
c.getChar();
c.println();
}
c.print("Malaska terminated.");
} // main method
public static void malaskaValue(boolean flagXF)
{
if (flagXF == true) // XF initiation
{
xfValueNew = (xfPosts * xfAge) / 100;
xfChange = xfValueNew - xfValueOld;
xfVPP = xfAge / 100;
}
else // Account value calculations
{
accountValueNew = accountVC * (accountPosts * accountAge) / 100;
if (confirm == 'n' || confirm == 'N')
{
accountChange = accountValueNew - accountValueOld;
accountROC = (accountChange / xfChange) * 100;
}
accountVPP = (accountAge * accountVC) / 100;
}
}// malaskaValue procedure
public static void copyToClipboard(boolean flagXF)
{
if (flagXF == true)
ubbc.setClipboardContents("[td][b]XF[/b][/td][td][b]" + wholecommas.format(xfPosts) + "[/b][/td][td][b]" + wholecommas.format(xfAge) + "[/b][/td][td] [/td][td][b]$" + decimalcommas.format(xfValueNew) + "[/b][/td][td][b][color=Green]" + decimalcommas.format(xfChange) + "[/color][/b][/td][td] [/td][td][b]$" + decimalcommas.format(xfVPP) + "[/b][/td][/tr]");
else if (accountChange > 0)
ubbc.setClipboardContents("[td]" + accountName + "[/td][td]" + wholecommas.format(accountPosts) + "[/td][td]" + wholecommas.format(accountAge) + "[/td][td]" + decimalcommas.format(accountVC) + "[/td][td][b]$" + decimalcommas.format(accountValueNew) + "[/b][/td][td][b][color=Green]$" + decimalcommas.format(accountChange) + "[/color][/b][/td][td]" + decimalcommas.format(accountROC) + "%[/td][td]$" + decimalcommas.format(accountVPP) + "[/td][/tr]");
else
ubbc.setClipboardContents("[td]" + accountName + "[/td][td]" + wholecommas.format(accountPosts) + "[/td][td]" + wholecommas.format(accountAge) + "[/td][td]" + decimalcommas.format(accountVC) + "[/td][td][b]$" + decimalcommas.format(accountValueNew) + "[/b][/td][td][b][color=Red]$" + decimalcommas.format(Math.abs(accountChange)) + "[/color][/b][/td][td]N/A[/td][td]$" + decimalcommas.format(accountVPP) + "[/td][/tr]");
}
public void lostOwnership( Clipboard aClipboard, Transferable aContents) // To make clipboard shit work
{
}
} // Malaska
The latest files can be found here. Please make any suggestions (code or otherwise).
Malaska Changelog
-----------------
0.4.0 BETA (2008-04-05)
---------------------
149 lines, 6,074 bytes (4,825 bytes compiled)
- UBBC code is now copied to the clipboard, complete with commas.
- Somewhat-better documentation.
0.3.1 BETA (2008-04-03)
---------------------
123 lines, 3,860 bytes (3,291 bytes compiled)
- Fixed an oversight regarding decimal points when initiating XF values.
0.3.0 BETA (2008-04-03)
---------------------
123 lines, 3,854 bytes (3,291 bytes compiled)
- The Console is now narrower, with Lost-style input thing for account name.
- Variables are now declared globally or at the beginning of the main method.
- XF stats can now be changed if there is an error rather than restarting Malaska.
- Calculations are now done in a seperate procedure, resulting in a smaller compiled size.
- Somewhat-better documentation.
- Answers to yes/no questions are now displayed.
- Decimal points have been removed from post and age displays.
- Pressing enter twice to terminate is now preferred and not a bug.
0.2.0 BETA (2008-03-20)
---------------------
104 lines, 3,280 bytes (2,533 bytes compiled)
- Line breaks fixed.
- ROC is now calculated to two decimal places.
- Support for new accounts added.
0.1.0 BETA (2008-03-19)
---------------------
- Formatting fix for XF initialization.
0.0.1 BETA (2008-03-18)
---------------------
- Initial release.
Malaska Roadmap
---------------
Major Features
--------------
- Integrate account age calculation capabilities.
- Store a statistics database locally.
- Use the ProBoards API to completely automate Malaska.
- Use a graphical user interface.
- Integrate account activity support (AAA) for generating posts-per-day tables.
- Use a modular system to extend Malaska beyond AVA.
- Convert Malaska to a Java applet for remote execution.
Minor Features
--------------
- There should be a terminate hotkey.
- Use a system of arrays rather than individual variables.
- Better code documentation is needed.
- Break long numbers with commas in the display along with the clipboard contents.
- Further code breakdown would be good.
Bug Fix Issues
--------------
- Code could be more streamlined, solid and efficient.