Computer Science Canada

Searching a File

Author:  Arrghus [ Wed Jan 10, 2007 10:09 am ]
Post subject:  Searching a File

I need to make a game for my Programming summative, and I'm making a combat system.

One of the parts I wanted to incorporate was spells, and I thought a sort of spell database would be the best way to achieve this.

The thought I had was that it would look through a file for the name of the spell, and from that point read the data that makes the spell work, and then cast it using this data. An example of a spell I've made is:

Cure
1
8
-30
-3
1A
None

The format being:
Name
Level
MP Cost
Damage
Damage Threshold
Target
Status Effect

Is there a way I can do this?

Author:  ericfourfour [ Wed Jan 10, 2007 4:53 pm ]
Post subject:  Re: Searching a File

Let me get you started:
Turing:
type Spell :
    record
        %insert variables for the spell
    end record

function readSpell (fileName : string) : Spell
    %Make the spell
    result %The new spell
end readSpell


Within the Turing Walkthrough, you will be able to find tutorials on records, functions, and file io.


: