MixItem.vb 4.74 KB
Newer Older
1
2
Imports Newtonsoft.Json
Public Class MixItem
3
4
    Private itemMix1 As Integer
    Private itemMix2 As Integer
Michael Alexander's avatar
Michael Alexander committed
5

6
7
8
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
9
10

    Private Sub MixItem_Load(sender As Object, e As EventArgs) Handles MyBase.Load
11
12
13
14
        RefreshInventory()
    End Sub

    Private Sub RefreshInventory()
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
        GlobalVariables.NETWORK = New NetIO
        Dim request As New InventoryJSONSend
        Dim recv As String

        recv = NETWORK.SendRecv(request)

        Dim recvjson As New InventoryJSONRecv
        recvjson = JsonConvert.DeserializeObject(Of InventoryJSONRecv)(recv)

        If (recvjson.status = "ok") Then
            LabelHoney.Text = recvjson.inventory(0) 'Honey
            LabelHerbs.Text = recvjson.inventory(1) 'Herbs
            LabelClay.Text = recvjson.inventory(2) 'Clay
            LabelMineral.Text = recvjson.inventory(3) 'Mineral
            LabelPotion.Text = recvjson.inventory(4) 'Potion
            LabelIncense.Text = recvjson.inventory(5) 'Incense
            LabelGems.Text = recvjson.inventory(6) 'Gems
            LabelLifeElixir.Text = recvjson.inventory(7) 'Life Elixir
            LabelManaCrystal.Text = recvjson.inventory(8) 'Mana Crystal
            LabelPhilosoperStone.Text = recvjson.inventory(9) 'Philosoper Stone
        End If
    End Sub
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133

    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click

    End Sub

    Private Sub DropdownOffer_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropdownOffer.SelectedIndexChanged
        Select Case DropdownOffer.SelectedItem.ToString()
            Case "Honey"
                OfferedPic.Image = PictureBox1.Image
                itemMix1 = 0
            Case "Herbs"
                OfferedPic.Image = PictureBox2.Image
                itemMix1 = 1
            Case "Clay"
                OfferedPic.Image = PictureBox3.Image
                itemMix1 = 2
            Case "Mineral"
                OfferedPic.Image = PictureBox4.Image
                itemMix1 = 3
            Case "Potion"
                OfferedPic.Image = PictureBox8.Image
                itemMix1 = 4
            Case "Incense"
                OfferedPic.Image = PictureBox9.Image
                itemMix1 = 5
            Case "Gems"
                OfferedPic.Image = PictureBox5.Image
                itemMix1 = 6
            Case "Life Elixir"
                OfferedPic.Image = PictureBox13.Image
                itemMix1 = 7
            Case "Mana Crystal"
                OfferedPic.Image = PictureBox12.Image
                itemMix1 = 8
            Case "Philosopher Stone"
                OfferedPic.Image = PictureBox11.Image
                itemMix1 = 9
        End Select
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        GlobalVariables.NETWORK = New NetIO
        Dim request As New MixItemJSONSend
        Dim recv As String

        request.item1 = itemMix1
        request.item2 = itemMix2

        recv = NETWORK.SendRecv(request)

        Dim recvjson As New MixItemJSONRecv
        recvjson = JsonConvert.DeserializeObject(Of MixItemJSONRecv)(recv)

        If (recvjson.status = "ok") Then
            MsgBox(recv)
            RefreshInventory()
        ElseIf (recvjson.status = "fail") Then
            MsgBox(recvjson.description)
        Else
            MsgBox("Unknown error occured!")
        End If
    End Sub

    Private Sub DropdownDemand_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropdownDemand.SelectedIndexChanged
        Select Case DropdownDemand.SelectedItem.ToString()
            Case "Honey"
                DemandedPic.Image = PictureBox1.Image
                itemMix2 = 0
            Case "Herbs"
                DemandedPic.Image = PictureBox2.Image
                itemMix2 = 1
            Case "Clay"
                DemandedPic.Image = PictureBox3.Image
                itemMix2 = 2
            Case "Mineral"
                DemandedPic.Image = PictureBox4.Image
                itemMix2 = 3
            Case "Potion"
                DemandedPic.Image = PictureBox8.Image
                itemMix2 = 4
            Case "Incense"
                DemandedPic.Image = PictureBox9.Image
                itemMix2 = 5
            Case "Gems"
                DemandedPic.Image = PictureBox5.Image
                itemMix2 = 6
            Case "Life Elixir"
                DemandedPic.Image = PictureBox13.Image
                itemMix2 = 7
            Case "Mana Crystal"
                DemandedPic.Image = PictureBox12.Image
                itemMix2 = 8
            Case "Philosopher Stone"
                DemandedPic.Image = PictureBox11.Image
                itemMix2 = 9
        End Select
    End Sub
Michael Alexander's avatar
Michael Alexander committed
134
End Class