Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
User Journal

Journal SurturZ's Journal: Hamurabi.vb

Module Module1
    Private mintPopulation As Integer 'a1
    Private mintArrived As Integer 'a2
    Private mintStarved As Integer 'a3
    Private mintBushelsStored As Integer 'b1
    Private mintRats As Integer 'b2
    Private mintBushelsPerAcre As Integer 'b3
    Private mintHarvest As Integer 'b4
    Private mintAcres As Integer 'c1
    Private mintLandPrice As Integer 'c2
    Private j As Integer
 
    Sub Main()
        Console.WriteLine("Hamurabi: Game of Hamurabi - Version 2.00")
        Console.WriteLine()
        Console.WriteLine("Original Hamurabi in IMSAI 4K BASIC")
        Console.WriteLine("v1.01 by Corona Data Systems, Inc. 11/12/1977")
        Console.WriteLine("This version 2.00 by David Streeter 19/09/2007")
        Console.WriteLine()
        Randomize()
        Console.WriteLine("Hamurabi - ")
        Console.WriteLine("Where you govern the ancient kingdom of Sumeria.")
        Console.WriteLine("The object is to figure out how the game works!!")
        Console.WriteLine("(If you want to quit, sell all your land)")
 
        mintPopulation = 100
        mintArrived = 5
        mintStarved = 0
        mintBushelsStored = 2800
        mintRats = 200
        mintBushelsPerAcre = 3
        mintHarvest = 3000
        mintAcres = 1000
        j = 1
        Do
            Console.WriteLine()
            Console.WriteLine("Hamurabi, I beg to report that last year")
            Console.Write(mintStarved.ToString & " people starved and ")
            If mintArrived >= 0 Then
                Console.WriteLine(mintArrived.ToString & " people came to the city")
            Else
                Console.WriteLine((-mintArrived).ToString & " people left the city")
            End If
            If j <= 0 Then
                mintPopulation = mintPopulation - CInt(mintPopulation / 2)
                Console.WriteLine("The plague killed half the people.")
            End If
            Console.WriteLine("The population is now " & mintPopulation.ToString)
            Console.WriteLine("We harvested " & mintHarvest.ToString & " bushels at " & mintBushelsPerAcre.ToString & " bushels per acre")
            Console.WriteLine("Rats destroyed " & mintRats.ToString & " bushels leaving " & mintBushelsStored.ToString & " bushels in the storehouses")
            Console.WriteLine("The city owns " & mintAcres.ToString & " acres of land.")
            mintLandPrice = 17 + CInt(6 * Rnd())
            Console.WriteLine("Land is worth " & mintLandPrice.ToString & " bushels per acre.")
            Console.WriteLine()
            Console.WriteLine("Hamurabi . . .")
1310: Console.WriteLine()
            Console.WriteLine("Buy how many acres?")
            Dim strBuy As String = Console.ReadLine()
            Dim intBuy As Integer = CInt(Math.Abs(Val(strBuy)))
            Console.WriteLine()
            If intBuy <> 0 Then
                j = intBuy * mintLandPrice
                If j > mintBushelsStored Then
                    Call ErrorMessage()
                    GoTo 1310 'love the GOTO
                End If
                mintBushelsStored -= j
                mintAcres += intBuy
            End If
1510: Console.WriteLine("Sell how many acres?")
            Dim strSell As String = Console.ReadLine()
            Console.WriteLine()
            Dim intSell As Integer = CInt(Math.Abs(Val(strSell)))
            Select Case intSell
                Case 0
                Case Is < mintAcres
                    mintAcres = mintAcres - intSell
                    mintBushelsStored += mintLandPrice * intSell
                Case mintAcres
                    Console.WriteLine("Game over. Press any key")
                    Console.ReadKey()
                    End
                Case Else
                    Call ErrorMessage()
                    GoTo 1510
            End Select
 
1710: Console.WriteLine("How many bushels shall we distribute as food?")
            Dim strFeed As String = Console.ReadLine
            Console.WriteLine()
            Dim intFeed As Integer = CInt(Math.Abs(Val(strFeed)))
            If intFeed > mintBushelsStored Then
                Call ErrorMessage()
                GoTo 1710
            End If
            mintBushelsStored -= intFeed
            mintStarved = mintPopulation - CInt(intFeed / 20)
            mintArrived = 0
            If mintStarved < 0 Then
                mintArrived = CInt(-mintStarved / 2)
                mintStarved = 0
            End If
 
1910: Console.WriteLine("How many acres shall we plant?")
            Dim strPlant As String = Console.ReadLine
            Console.WriteLine()
            Dim intPlant As Integer = CInt(Math.Abs(Val(strPlant)))
            If intPlant > mintAcres Then
                Call ErrorMessage()
                GoTo 1910
            End If
            j = CInt(intPlant / 2)
            If j > mintBushelsStored Then
                Call ErrorMessage()
                GoTo 1910
            End If
 
            If intPlant > 10 * mintPopulation Then
                Call ErrorMessage()
                GoTo 1910
            End If
            mintBushelsStored -= j
            mintBushelsPerAcre = CInt(5 * Rnd()) + 1
            mintHarvest = mintBushelsPerAcre * intPlant
            mintRats = CInt((mintBushelsStored + mintHarvest) * 0.07 * Rnd())
            mintBushelsStored = mintBushelsStored - mintRats + mintHarvest
            j = CInt(10 * Rnd()) '10% chance of plague
            mintArrived = CInt(mintArrived + (5 - mintBushelsPerAcre) * mintBushelsStored / 600 + 1)
            If mintArrived > 50 Then mintArrived = 50
            mintPopulation = mintPopulation + mintArrived - mintStarved
            If mintPopulation < 0 Then mintPopulation = 0
        Loop
    End Sub
 
    Private Sub ErrorMessage()
        Console.WriteLine("Hamurabi, think again - ")
        Console.WriteLine("You only have " & mintPopulation & " people, " & mintAcres.ToString & " acres, and " & mintBushelsStored.ToString & " bushels in storehouses")
    End Sub
 
End Module

This discussion has been archived. No new comments can be posted.

Hamurabi.vb

Comments Filter:

The one day you'd sell your soul for something, souls are a glut.

Working...