now generates completely. i shall say, v0.9. Added SBT.

master
Henry Jameson 11 years ago
parent 83f0e9a869
commit eb7a09fc19
  1. 1
      .gitignore
  2. 7
      build.sbt
  3. 1
      project/plugins.sbt
  4. 9
      src/Launcher.scala
  5. 38
      src/main/scala/org/hjiri/weapass/Launcher.scala
  6. 2
      src/main/scala/org/hjiri/weapass/Randomizer.scala
  7. 2
      src/main/scala/org/hjiri/weapass/Rarity.scala
  8. 2
      src/main/scala/org/hjiri/weapass/Syllable.scala
  9. 12
      src/main/scala/org/hjiri/weapass/SyllableGenerator.scala
  10. 2
      src/main/scala/org/hjiri/weapass/Word.scala
  11. 4
      src/main/scala/org/hjiri/weapass/WordGenerator.scala
  12. 48
      src/testing.sc

1
.gitignore vendored

@ -15,6 +15,7 @@ local.properties
.classpath
.settings/
.loadpath
target
# External tool builders
.externalToolBuilders/

@ -0,0 +1,7 @@
name := "Weeapass"
version := "1.0"
scalaVersion := "2.10.1"
libraryDependencies += "com.beust" % "jcommander" % "1.30"

@ -0,0 +1 @@
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.4.0")

@ -1,9 +0,0 @@
/**
* Created with IntelliJ IDEA.
* User: jcd
* Date: 4/25/13
* Time: 9:46 PM
*/
object Launcher extends App{
}

@ -0,0 +1,38 @@
package org.hjiri.weapass
import com.beust.jcommander.{JCommander, Parameter}
/**
* Created with IntelliJ IDEA.
* User: jcd
* Date: 4/25/13
* Time: 9:46 PM
*/
object Launcher extends App{
object Args {
// Declared as var because JCommander assigns a new collection declared
// as java.util.List because that's what JCommander will replace it with.
// It'd be nice if JCommander would just use the provided List so this
// could be a val and a Scala LinkedList.
@Parameter(
names = Array("-l"),
description = "When genelatingu wolds use L instead of R")
var lefto: Boolean = false
@Parameter(
names = Array("-s"),
description = "When generating wordsh ushe S instead of SH")
var shisi: Boolean = false
}
if (args != null){
new JCommander(Args, args.toArray : _*)
}
val s:SyllableGenerator = new SyllableGenerator(!Args.shisi, !Args.lefto)
val w:WordGenerator = new WordGenerator(s)
for (i <- 1 to Randomizer.pickInt(2,5)){
System.out.print (w.generateWord.toString+" ")
}
}

@ -1,3 +1,5 @@
package org.hjiri.weapass
import scala.util.Random
/**

@ -1,3 +1,5 @@
package org.hjiri.weapass
/**
* Created with IntelliJ IDEA.
* User: jcd

@ -1,3 +1,5 @@
package org.hjiri.weapass
/**
* Created with IntelliJ IDEA.
* User: jcd

@ -1,10 +1,12 @@
package org.hjiri.weapass
/**
* Created with IntelliJ IDEA.
* User: jcd
* Date: 4/25/13
* Time: 9:54 PM
*/
class SyllableGenerator (val useX: Boolean, val sInsteadOfsh: Boolean = false, val righto: Boolean = true){
class SyllableGenerator (val sInsteadOfsh: Boolean = false, val righto: Boolean = true){
val sh = if (sInsteadOfsh) "s" else "sh"
val r = if (righto) "r" else "l"
val j = "j" // add option to replace with z?
@ -34,13 +36,13 @@ class SyllableGenerator (val useX: Boolean, val sInsteadOfsh: Boolean = false, v
val rarity =
if (youonForce){
Rarity.Youon
} else if (Randomizer.pickWithProb(0.50)){
} else if (Randomizer.pickWithProb(0.80)){
Rarity.Common
} else if (Randomizer.pickWithProb(0.50)){
} else if (Randomizer.pickWithProb(0.70)){
Rarity.Uncommon
} else if (Randomizer.pickWithProb(0.50)){
} else if (Randomizer.pickWithProb(0.60)){
Rarity.Youon
} else if (Randomizer.pickWithProb(0.50)){
} else if (Randomizer.pickWithProb(0.75)){
Rarity.Epic
} else {
Rarity.EpicAlt

@ -1,3 +1,5 @@
package org.hjiri.weapass
/**
* Created with IntelliJ IDEA.
* User: jcd

@ -1,3 +1,5 @@
package org.hjiri.weapass
/**
* Created with IntelliJ IDEA.
* User: jcd
@ -12,7 +14,7 @@ class WordGenerator(val sg:SyllableGenerator) {
val syllable =
if ((0 to 5 contains(word.n())) && Randomizer.pickWithProb(0.25)){
sg.generateSyllableV(useN = true)
} else if ((0 to 25 contains(word.vsyl())) && Randomizer.pickWithProb(0.49)){
} else if ((0 to 15 contains(word.vsyl())) && Randomizer.pickWithProb(0.25)){
sg.generateSyllableV(useN = false)
} else {
sg.generateSyllableF(youonForce = false, youonProhibit = lastYouon)

@ -1,48 +0,0 @@
/**
* Created with IntelliJ IDEA.
* User: jcd
* Date: 4/25/13
* Time: 10:43 PM
*
* sample workspace file to view how generator behaves.
*/
val s:SyllableGenerator = new SyllableGenerator(false, false, true)
val w:WordGenerator = new WordGenerator(s)
for (i <- 1 to 28){
System.out.println (w.generateWord.toString+" ")
}
Loading…
Cancel
Save