コード例 #1
0
ファイル: sample2.go プロジェクト: adsr/gocurse
func stopGoCurses() {
	curses.Endwin()
}
コード例 #2
0
ファイル: main.go プロジェクト: serraavenger/gokemon
func main() {

	testmode := true
	Darkness := TestElement("Darkness")
	Light := TestElement("Light")
	Metal := TestElement("Metal")
	Fire := TestElement("Fire")

	Light.SetDamageMod(Metal, INEFFECTIVE)
	Darkness.SetDamageMod(Metal, INEFFECTIVE)
	Darkness.SetDamageMod(Light, SUPER_EFFECTIVE)
	Fire.SetDamageMod(Metal, SUPER_EFFECTIVE)
	//Metal.SetDamageMod(Darkness, SUPER_EFFECTIVE )

	//  80 => +8
	//  90 => +9
	// 100 => +10

	ava := TestCreature("Avatark",
		25, 80, 45, 70,
		12,
		Darkness,
	)

	fla := TestCreature("Flamex",
		170, 5, 45, 0,
		12,
		Fire,
	)

	ste := TestCreature("Steerox",
		65, 40, 80, 35,
		12,
		Metal,
	)

	if testmode {
		ava.SyncAccess(func() {
			name := ava.GetName()
			if "Avatark" != name {
				fmt.Println(name, "!=", "Avatark")
			}
			name = "John"
			if ava.SetName(name); ava.GetName() != name {
				fmt.Println(ava.GetName(), "!=", name)
			}
			name = "Avatark"
			if ava.SetName(name); ava.GetName() != name {
				fmt.Println(ava.GetName(), "!=", name)
			}

			str := ava.GetStrength()
			if ava.SetStrength(str); ava.GetStrength() != str || ava.GetStrength() != 40 {
				fmt.Println(ava.GetStrength(), "!=", str)
			}
		})

	}

	a := MainWorld.GetSingleArena()

	ava_com := TestCombattant(ava)
	fla_com := TestCombattant(fla)
	ste_com := TestCombattant(ste)

	a.SyncAccess(func() {

		if testmode {

			if ava.GetName() != ava_com.GetName() {
				fmt.Println(ava.GetName(), "!=", ava_com.GetName())
			}
			if ste.GetName() != ste_com.GetName() {
				fmt.Println(ste.GetName(), "!=", ste_com.GetName())
			}

			ava_com.SetStrength(45)
			ste_com.SetStrength(65)

			if ava.GetStrength() != 25 {
				fmt.Println(ava.GetStrength(), "!=", 25)
			}
			if ste.GetStrength() != 65 {
				fmt.Println(ste.GetStrength(), "!=", 65)
			}

			if ava_com.GetStrength() != 45 {
				fmt.Println(ava_com.GetStrength(), "!=", 45)
			}
			if ste_com.GetStrength() != 65 {
				fmt.Println(ste_com.GetStrength(), "!=", 65)
			}

			ava_com.SetStrength(25)
			ste_com.SetStrength(65)

		}

		a.SetCombattant(0, fla_com)

		a.SetCombattant(1, ste_com)
		a.SetCombattant(0, ava_com)

		if testmode {

			first, _ := a.GetCombattant(0)
			if first != ava_com {
				fmt.Println(first.GetName(), "!=", ava_com.GetName())
			}
			second, _ := a.GetCombattant(1)
			if second != ste_com {
				fmt.Println(second.GetName(), "!=", ste_com.GetName())
			}

			f_mod := first.GetArenaSpeedMod(a)
			s_mod := second.GetArenaSpeedMod(a)

			if f_mod != 1 {
				fmt.Println(f_mod, "!=", 1)
			}
			if s_mod <= f_mod {
				fmt.Println(s_mod, "<=", f_mod)
			}

		}
	})

	if _, err := curses.Initscr(); err != nil {
		panic("Window could not be initialised")
	}

	char.Start()
	defer curses.Endwin()
	curses.Stdwin.Addstr(0, 0, "Start?", curses.A_NORMAL)

	curses.Noecho()
	curses.Curs_set(curses.CURS_HIDE)
	curses.Stdwin.Keypad(true)
	curses.Stdwin.Refresh()
	char.GetWithTimeout(5e9)

	go func() {
		time_c := time.Tick(1e8)
		for _ = range time_c {
			if char.GetLast() == 'q' {
				break
			}
		}
		mainCIn <- true
		mainQuit <- true
	}()

	c1, _ := a.GetCombattant(0)
	c2, _ := a.GetCombattant(1)

	var foo1, foo2 func()

	p1 := TestSpecPower("Dark Ray", 30, 1.0, 3.0, Darkness)
	p2 := TestPhysPower("Metal Claw", 30, 1.0, 3.0, Metal)
	p3 := TestPhysPower("Flame Fist", 20, 1.0, 2.0, Fire)

	ava.AddPower(p1)
	ste.AddPower(p2)
	fla.AddPower(p3)

	foo1 = func() {
		MainWorld.PauseCombat(true)

		if c1.GetHp() > 0 {
			for p := range c1.GetPowers() {
				if p != nil {
					p.Use()
				}
			}
			if c2.GetHp() > 0 {
				sleep(c1, foo1)
			} else {
				a.SetCombattant(1, nil)
			}
		}

		MainWorld.PauseCombat(false)
	}

	foo2 = func() {
		MainWorld.PauseCombat(true)

		if c2.GetHp() > 0 {
			for p := range c1.GetPowers() {
				if p != nil {
					p.Use()
				}
			}
			if c1.GetHp() > 0 {
				sleep(c2, foo2)
			} else {
				a.SetCombattant(0, nil)
			}
		}

		MainWorld.PauseCombat(false)
	}

	if c1.SetSleepTime(a, 3e9) {
		sleep(c1, foo1)
	}

	if c2.SetSleepTime(a, 3e9) {
		sleep(c2, foo2)
	}

	rand.Seed(time.Nanoseconds())
	go mainloop()
	go viewloop()

	<-mainQuit
}
コード例 #3
0
ファイル: d.go プロジェクト: dforsyth/dvi-go
func EndScreen() {
	curses.Endwin()
}
コード例 #4
0
ファイル: draw.go プロジェクト: dforsyth/dvi-go
func endscreen() {
	curses.Endwin()
}