Difference between pages "Mood" and "Compiling from Source"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>Relyk
 
(Adding build steps for Linux, someone who knows more please fix)
 
Line 1: Line 1:
A mood is a set of triggers that are executed after an adventure.
+
=== GREAT BIG NEWS ===
  
== Interface ==
+
==KoLmafia has migrated to the GitHub repository and we are retooling for GIT and gradle builds.==
 +
Exactly nothing below here is accurate, and we'll need to do a thorough cleanup of this page and the IDE setup page.
  
=== Buttons ===
+
The good news is that the IDE setup is a lot easier. The bad news is you'll need to take some steps to build anything. In addition, we are discussing changing to a newer required JDK, so even these instructions will not be permanent.
; Settings
 
* Trigger On: The trigger to check the mood for an action.
 
* Check For: The condition required to take an action.
 
* Command: The [[CLI Reference|CLI]] command to execute.
 
  
; Controls
 
* add entry - Add an entry to the mood with the current settings.
 
* auto-fill
 
** minimal set - Adds all current active effects on the player. Users will find this function extremely useful.
 
** maximal set - Adds the castable buffs availabe to the player. This only includes buffs available from skills.
 
  
; Management
 
* Active mood - A drop-list of moods with the curent active mood. The scroll box lists all triggers for the active mood.
 
* new list - Create a new mood. Entering the name of an existing mood will set it as active.
 
* delete list - Deletes the current active mood selected.
 
* copy list - Copy the current triggers of the active mood into a new mood. This will replace the mood if it exists.
 
* execute - Execute the current mood.
 
  
=== Triggers ===
+
To contribute to the Mafia project, you'll need to be able to install the Java Development Kit, connect to the SVN and be comfortable writing Java Code. Instructions for the first two are included below:
There are three types of triggers in the drop-down list. A trigger is checked upon the completion of an adventure or prompt from the user.
 
* When an effect is lost - An effect is no longer active on the character.
 
* When an effect is gained - An effect is active on the character.
 
* Unconditional trigger - Trigger command is executed every time.
 
  
=== Condition ===
+
==Windows==
If the trigger is for an effect, the field is a drop-down list of all the effects in the game. The interface will fuzzy match to what the user types in. In addition, the interface will match common abbreviations such as "sss" matching to "Shortie Shaman Shurprise" and "Stevedave's Shanty of Superiority". The filtering is quite robust. For example, the interface will accept "2020" as matching to 20/20 Vision.
+
# Download Tools
 +
## Download and install Java Development Kit 1.8 or newer, available from [https://www.oracle.com/java/technologies/javase-downloads.html Oracle] or [https://adoptopenjdk.net AdoptOpenJDK]
 +
## Download and install Subversion, from [https://subversion.apache.org/packages.html apache.org]
 +
## Download and install Tortoise SVN (or of course, another SVN program)from [https://tortoisesvn.net/downloads.html tortoisesvn]
 +
## Download and install ANT, from [https://ant.apache.org/bindownload.cgi apache.org]
 +
# Configure Windows Environment Variables[[File:Environment vars.jpg|thumb|Win 10 Environment Variable Editor]]
 +
## Windows 10
 +
### Go to settings
 +
### type 'enviro' in the search
 +
### click on the 'edit environment variables' suggestion
 +
### add or edit ANT_HOME, JAVA_HOME, and PATH variables<br>''PATH should include ANT_HOME/bin and JAVA_HOME''</br>If ANT or JAVA installers have already set these variables, they can be updated or left alone.
 +
# Get Source and Build
 +
## Connect to the SVN server and download the source code for the Mafia Project. Using Tortoise SVN, you have to right-click on your desktop, select "SVN Checkout", and put the URL of the repository as "svn://svn.code.sf.net/p/kolmafia/code/". Leave all other settings as they are, and click OK.
 +
## Copy %ANT_HOME%/bin/ant.bat to your Desktop/kolmafia/ folder. If you have set up ANT correctly (and it's hard not to - there aren't many options) then double clicking on this file should compile the program.
 +
# Compiling creates a "build" and "dist" folder. The end program is in dist/Kolmafia.jar.
 +
===Troubleshooting===
 +
====Double-Clicking ''ant.bat''====
 +
Due to how bat files work when you double-click them, ''ant.bat'' will auto-close before you can read its output.
 +
# ant assumes that builds are done from a command shell.  You'll need to run from the command shell to execute any ant target other than the default, such as ''ant.bat update exec'' or ''ant.bat daily</br>ant -projecthelp'' will list all main targets
 +
# An easy workaround is to add a "pause" near the bottom of the file before it has a chance to auto-close on you.<br>When you run it again, you'll be able to read its output and it will exit after you ''Press any key to continue...''
 +
# Alternatively, you can create a wrapper batch file that calls the existing ''ant.bat'' file and adds a pause after executing it.  This method allows you to set different ant targets and also prevents updates to ant from overwriting your modifications.
 +
<blockquote>Example of a very simple MyWrapper.bat file<pre>
 +
# This is a wrapper batch file
 +
# First it runs ant
 +
call ant.bat daily
 +
# Then it pauses
 +
pause</pre></blockquote>
  
Unconditional triggers will always execute the command and does not allow the user to add a condition.
+
====''tools.jar'' not found====
 +
If you get an error message about "tools.jar" not being found, this means you're trying to build with the JRE (which doesn't contain this file) rather than the JDK (which contains it).<br>
 +
To fix this, right click on ''my computer'' -> ''properties'' -> ''advanced system settings'' -> ''Environment Variables...'' then make sure your PATH contains a reference to the location of your JDK directory.
  
=== Command ===
+
==Linux==
The command is a [[CLI Reference|CLI]] command. The command will be executed if the condition for the trigger is true. Unconditional triggers are primarily for advanced users as it requires familiarity with the CLI and scripting. Typical usage is to use an if statement to check for the condition and then excute a command. See [[CLI Reference#Scripting|CLI scripting]] for control structures avaialble for scripting.
 
  
== Using the CLI ==
+
# Install Sun Java Development Kit ( debian: apt-get install sun-java6-jdk )
Moods are can be managed through the CLI using "mood" and "trigger" commands.
+
# Install Subversion ( debian: apt-get install svn )
 +
# Install Ant ( debian: apt-get install ant )
 +
# Connect to the SVN server and download the source code for the Mafia Project. ( svn checkout svn://svn.code.sf.net/p/kolmafia/code/ kolmafia )
 +
# Verify tou are using sun-java with ( debian: update-alternatives --all )
 +
# I had to change $JAVA_HOME to compile ( export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.12 )
 +
# Compile kolmafia with Ant ( debian: cd kolmafia && ant debian )
 +
# Install kolmafia ( debian: cd dist && dpkg -i kolmafia*.deb )
  
<pre>
 
mood* list | listall | clear | autofill | execute | repeat [numTimes] | moodName [numTimes] - mood management.
 
trigger* list | clear | autofill | [type,] effect [, action] - edit current mood
 
</pre>
 
  
;mood
+
'''Above may be out of date.''' As of the move to github the following commands were successful to build from source on Ubuntu 20.04.1 LTS. You will still have to have a jdk installed.<pre>mkdir kolmafia
* <code>mood</code> - List all triggers for current mood. Equivalent to <code>trigger list</code>.
+
cd kolmafia
* <code>mood list</code> - List all saved moods including active mood.
+
git init
* <code>mood clear</code> - Remove all triggers from the current mood. Ignores composable moods.
+
git remote add origin https://github.com/kolmafia/kolmafia.git
* <code>mood autofill</code> - List current moods available.
+
git fetch
* <code>mood repeat [numTimes]</code> - Execute current mood number of times. Default to 1.
+
git reset --hard origin/main
* <code>mood <mood> [numTimes]</code> - Execute the given mood number of times. Default to 1. If mood doesn't exist, does nothing.
+
./gradlew --no-daemon clean shadowJar</pre>
 +
===Fedora (or probably other RPM systems)===
  
;[[trigger]]
+
# Install Subversion: <pre>sudo yum install sqlite-devel subversion </pre>
See the page for information.
+
# Install Java JDK: <pre>sudo yum install java-latest-openjdk-devel</pre>
 +
# Install Ant: <pre>sudo yum install ant</pre>
 +
# Checkout: <pre>svn checkout svn://svn.code.sf.net/p/kolmafia/code/ kolmafia</pre>
 +
# Build: <pre>cd kolmafia && ant</pre>
  
== Composable moods ==
 
Composable moods can be used to combine a set of moods together. Composable moods are handled through the CLI as the interface doesn't have equivalent functionality.
 
  
<pre>
+
You have a KoLmafia jar file that can be invoked with <pre>java -jar dist/KoLmafia-*.jar</pre>
<mood> extends <mood>[, mood]
 
</pre>
 
  
A composable mood is treated just like a normal mood but multiple moods. In addition, triggers can be added and removed from the mood itself. If you want to clear all the moods the composable mood is referencing without removing triggers specific to the mood, you can extend the "apathetic" mood.
+
Do other installation steps as you wish.
  
<pre>
+
==MacOSX==
mood default extends apathetic
+
# Install required packages</br>''MacOS X packages for Java, subversion, and ANT may also be installed via a package manager like [https://brew.sh Homebrew] or [https://www.macports.org MacPorts].  The instructions are written for a direct installation of the packages.''
</pre>
+
## Install Java Development Kit version 1.8 or newer from [https://www.oracle.com/java/technologies/javase-downloads.html Oracle] or [https://adoptium.net Adoptium Temurin]
 +
## Install git:  Atlassian has a great document on [https://www.atlassian.com/git/tutorials/install-git the various ways to install Git]
 +
# Configure development environment</br>Most of these steps can be included in ''.profile'' or the equivalent for your terminal of choice.
 +
## In the terminal set JAVA_HOME to the java home directory. </br>''/usr/libexec/java_home -V'' will list all known values for java_home.</br>If you have multiple copies of java, choose the version you want to us''e.
 +
# Open a new terminal window and navigate to the directory to which you wish to create kolmafia (e.g. cd ~/Projects, or some similar directory)
 +
# Clone the source code for the KoLmafia Project.</br>''git clone git@github.com:kolmafia/kolmafia.git''
 +
# Compile KoLmafia with the Gradle wrapper (''cd kolmafia && ./gradlew runShadow'')
 +
''There are more instructions on setting up your token in GitHub and then setting up ssh-agent, as well as how to update your cloned copy.  TBD''
  
Anonymous composable moods can be created by using a list of existing moods. Anonymous moods are temporary and will disappear when the mood is changed or the session ends. This is useful when you don't want to create a new mood every time.
+
''[[Category:Tech Support]]''
 
 
<pre>
 
mood combat, item, sea
 
</pre>
 
 
 
=== Example ===
 
A common example is a player making a farming mood. Instead of creating a mood for effects that increase item and meat in a single list, the player creates a "item" and "meat" mood. The player then defines a "farm" mood consisting of the item and meat moods.
 
 
 
<pre>
 
mood farm extends item, meat
 
</pre>
 
 
 
[[Category:Automation]]
 

Revision as of 15:03, 29 September 2021

GREAT BIG NEWS

KoLmafia has migrated to the GitHub repository and we are retooling for GIT and gradle builds.

Exactly nothing below here is accurate, and we'll need to do a thorough cleanup of this page and the IDE setup page.

The good news is that the IDE setup is a lot easier. The bad news is you'll need to take some steps to build anything. In addition, we are discussing changing to a newer required JDK, so even these instructions will not be permanent.


To contribute to the Mafia project, you'll need to be able to install the Java Development Kit, connect to the SVN and be comfortable writing Java Code. Instructions for the first two are included below:

Windows

  1. Download Tools
    1. Download and install Java Development Kit 1.8 or newer, available from Oracle or AdoptOpenJDK
    2. Download and install Subversion, from apache.org
    3. Download and install Tortoise SVN (or of course, another SVN program)from tortoisesvn
    4. Download and install ANT, from apache.org
  2. Configure Windows Environment Variables
    Win 10 Environment Variable Editor
    1. Windows 10
      1. Go to settings
      2. type 'enviro' in the search
      3. click on the 'edit environment variables' suggestion
      4. add or edit ANT_HOME, JAVA_HOME, and PATH variables
        PATH should include ANT_HOME/bin and JAVA_HOME
        If ANT or JAVA installers have already set these variables, they can be updated or left alone.
  3. Get Source and Build
    1. Connect to the SVN server and download the source code for the Mafia Project. Using Tortoise SVN, you have to right-click on your desktop, select "SVN Checkout", and put the URL of the repository as "svn://svn.code.sf.net/p/kolmafia/code/". Leave all other settings as they are, and click OK.
    2. Copy %ANT_HOME%/bin/ant.bat to your Desktop/kolmafia/ folder. If you have set up ANT correctly (and it's hard not to - there aren't many options) then double clicking on this file should compile the program.
  4. Compiling creates a "build" and "dist" folder. The end program is in dist/Kolmafia.jar.

Troubleshooting

Double-Clicking ant.bat

Due to how bat files work when you double-click them, ant.bat will auto-close before you can read its output.

  1. ant assumes that builds are done from a command shell. You'll need to run from the command shell to execute any ant target other than the default, such as ant.bat update exec or ant.bat daily
    ant -projecthelp
    will list all main targets
  2. An easy workaround is to add a "pause" near the bottom of the file before it has a chance to auto-close on you.
    When you run it again, you'll be able to read its output and it will exit after you Press any key to continue...
  3. Alternatively, you can create a wrapper batch file that calls the existing ant.bat file and adds a pause after executing it. This method allows you to set different ant targets and also prevents updates to ant from overwriting your modifications.

Example of a very simple MyWrapper.bat file

# This is a wrapper batch file
# First it runs ant
call ant.bat daily
# Then it pauses
pause

tools.jar not found

If you get an error message about "tools.jar" not being found, this means you're trying to build with the JRE (which doesn't contain this file) rather than the JDK (which contains it).
To fix this, right click on my computer -> properties -> advanced system settings -> Environment Variables... then make sure your PATH contains a reference to the location of your JDK directory.

Linux

  1. Install Sun Java Development Kit ( debian: apt-get install sun-java6-jdk )
  2. Install Subversion ( debian: apt-get install svn )
  3. Install Ant ( debian: apt-get install ant )
  4. Connect to the SVN server and download the source code for the Mafia Project. ( svn checkout svn://svn.code.sf.net/p/kolmafia/code/ kolmafia )
  5. Verify tou are using sun-java with ( debian: update-alternatives --all )
  6. I had to change $JAVA_HOME to compile ( export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.12 )
  7. Compile kolmafia with Ant ( debian: cd kolmafia && ant debian )
  8. Install kolmafia ( debian: cd dist && dpkg -i kolmafia*.deb )


Above may be out of date. As of the move to github the following commands were successful to build from source on Ubuntu 20.04.1 LTS. You will still have to have a jdk installed.

mkdir kolmafia
cd kolmafia
git init
git remote add origin https://github.com/kolmafia/kolmafia.git
git fetch
git reset --hard origin/main
./gradlew --no-daemon clean shadowJar

Fedora (or probably other RPM systems)

  1. Install Subversion:
    sudo yum install sqlite-devel subversion 
  2. Install Java JDK:
    sudo yum install java-latest-openjdk-devel
  3. Install Ant:
    sudo yum install ant
  4. Checkout:
    svn checkout svn://svn.code.sf.net/p/kolmafia/code/ kolmafia
  5. Build:
    cd kolmafia && ant


You have a KoLmafia jar file that can be invoked with

java -jar dist/KoLmafia-*.jar

Do other installation steps as you wish.

MacOSX

  1. Install required packages
    MacOS X packages for Java, subversion, and ANT may also be installed via a package manager like Homebrew or MacPorts. The instructions are written for a direct installation of the packages.
    1. Install Java Development Kit version 1.8 or newer from Oracle or Adoptium Temurin
    2. Install git: Atlassian has a great document on the various ways to install Git
  2. Configure development environment
    Most of these steps can be included in .profile or the equivalent for your terminal of choice.
    1. In the terminal set JAVA_HOME to the java home directory.
      /usr/libexec/java_home -V will list all known values for java_home.
      If you have multiple copies of java, choose the version you want to use.
  3. Open a new terminal window and navigate to the directory to which you wish to create kolmafia (e.g. cd ~/Projects, or some similar directory)
  4. Clone the source code for the KoLmafia Project.
    git clone git@github.com:kolmafia/kolmafia.git
  5. Compile KoLmafia with the Gradle wrapper (cd kolmafia && ./gradlew runShadow)

There are more instructions on setting up your token in GitHub and then setting up ssh-agent, as well as how to update your cloned copy. TBD

'