2023年12月29日 星期五

中打大富翁對話邏輯備份

typegame_speech
> mode 0
>> after=0 對話直接結束
>> after>0 出現下一個選單 (通常最後會到一個 mode 1 的對話)

> mode 1
>> 出現問題選單 選單內容:
>> qus_sp 的 part
>> 正確回答問題 r_mission
>> 錯誤回答問題 w_mission
>>> 導引至任務資料庫 typegame_speech_misson
>>> mode 0
>>>> 傳送、製作、消耗物品等
>>> mode 1
>>>> 特殊任務

2023年8月28日 星期一

採購法筆記

法規名稱: 機關委託技術服務廠商評選及計費辦法

【服務費用採服務成本加公費法】

 1.全部管理費用不得超過直接薪資扣除非經常性給與之獎金後之百分之一百。

2.工作人員不扣薪假與特別休假之薪資費用,免檢據核銷。但不得超過實際薪資之百分之十六。

3.非經常性給與之獎金為實際薪資之一定比率及給付條件,檢據核銷。但不得超過實際薪資之百分之三十。

4.公費,應為定額,全部公費不得超過直接薪資扣除非經常性給與之獎金後與管理費用合計金額之百分之二十五。


採購爭議

1.廠商對於機關依前條所為之通知,認為違反本法或不實者,得於接獲通知之次日起二十日內,以書面向該機關提出異議


應刊登採購公報的情況

下列政府採購資訊應刊登採購公報一日,並公開於主管機關之政府採購資訊網站(以下簡稱採購網站):

一、本法第二十二條第一項第九款至第十一款、第十四款規定之公開評選、公開徵求或審查之公告。

二、本法第二十七條第一項規定之招標公告及辦理資格審查之公告。

三、本法第四十一條第二項規定之變更或補充招標文件內容之公告及必要之釋疑公告。

四、本法第六十一條規定之決標結果或無法決標之公告。

五、本法第七十五條第二項規定應另行辦理之變更或補充招標文件內容之公告。

六、本法第一百零二條第三項規定之廠商名稱與相關情形。

七、本法第一百零三條第一項規定之註銷公告。


機關辦理特殊或巨額採購,可就下列事項擇定投標廠商之特定資格

1.截止投標日前五年內,完成與招標標的同性質或相當之工程、財物或勞務契約,其單次契約金額或數量不低於招標標的預算金額或數量之五分之二,或累計金額或數量不低於招標標的預算金額或數量

2.具有相當財力者。其範圍得包括實收資本額不低於招標標的預算金額之十分之一

3.權益不低於招標標的預算金額十二分之一

4.流動資產不低於流動負債

5.總負債金額不超過權益四倍。但配合民營化政策之公營事業參加投標者,不在此限


2023年7月8日 星期六

[python]使用滑鼠指定範圍螢幕截圖,儲存截圖+將截圖寫入剪貼簿

 1.安裝元件

pip install opencv-python

2.參考程式碼
import cv2
import time,PIL,os
from PIL import ImageGrab
import numpy as np
import tkinter as tk
from tkinter import *
import win32clipboard as clip
from ctypes import *
import win32con

window = tk.Tk()
window.wm_attributes('-topmost',1)  #固定最上層
window.wm_attributes('-toolwindow',1)  #去除最大最小化按鈕
window.resizable(0,0)  #禁止改變大小
window.title('螢幕截圖')
window.geometry("270x170+1370+250")
window.focus_set()
#截图
def cut():
    global img
    scrren_cut()
    img = cv2.imread('screen.jpg')
    cv2.namedWindow('image')
    cv2.setMouseCallback('image', on_mouse)
    cv2.imshow('image', img)
    cv2.waitKey(0)
    os.remove('screen.jpg')
def scrren_cut():
    beg = time.time()
    debug = False
    # img = ImageGrab.grab(bbox=(250, 161, 1141, 610))
    image = ImageGrab.grab()
    image.save("screen.jpg")
    # PIL image to OpenCV image
def on_mouse(event, x, y, flags, param):
    global img, point1, point2
    img2 = img.copy()
    if event == cv2.EVENT_LBUTTONDOWN:         #左鍵點擊
        point1 = (x,y)
        cv2.circle(img2, point1, 10, (0,255,0), 5)
        cv2.imshow('image', img2)
    elif event == cv2.EVENT_MOUSEMOVE and (flags & cv2.EVENT_FLAG_LBUTTON):               #按住左鍵拖曳
        cv2.rectangle(img2, point1, (x,y), (255,0,0), 5)
        cv2.imshow('image', img2)
    elif event == cv2.EVENT_LBUTTONUP:         #左鍵放開
        point2 = (x,y)
        cv2.rectangle(img2, point1, point2, (0,0,255), 5)
        cv2.imshow('image', img2)
        min_x = min(point1[0],point2[0])    
        min_y = min(point1[1],point2[1])
        width = abs(point1[0] - point2[0])
        height = abs(point1[1] -point2[1])
        cut_img = img[min_y:min_y+height, min_x:min_x+width]
        cv2.imwrite('cut.bmp', cut_img)

        aString=windll.user32.LoadImageW(0,"cut.bmp",win32con.IMAGE_BITMAP,0,0,win32con.LR_LOADFROMFILE)
        print(aString)
        if aString !=0: ## 寫入剪貼簿並關閉CV視窗
            clip.OpenClipboard()
            clip.EmptyClipboard()
            clip.SetClipboardData(win32con.CF_BITMAP, aString)
            clip.CloseClipboard()
            cv2.destroyAllWindows()

window.bind("<F11>",lambda event:cut()) #F11截圖

window.mainloop()

2023年6月20日 星期二

python繪圖前準備

 NumPy 安装

pip3 install --user numpy scipy matplotlib


補充安裝

pip install msvc-runtime


測試用程式碼

import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
# Dataset generation
a, b, c = 10., 28., 8. / 3.
def lorenz_map(x, dt = 1e-2):
    x_dt = np.array([a * (x[1] - x[0]), x[0] * (b - x[2]) - x[1], x[0] * x[1] - c * x[2]])
    return x + dt * x_dt
points = np.zeros((2000, 3))
x = np.array([.1, .0, .0])
for i in range(points.shape[0]):
    points[i], x = x, lorenz_map(x)
# Plotting
fig = plt.figure()
ax = fig.gca(projection = '3d')
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
ax.set_title('Lorenz Attractor a=%0.2f b=%0.2f c=%0.2f' % (a, b, c))
ax.scatter(points[:, 0], points[:, 1],points[:, 2], zdir = 'z', c = 'c')
plt.show()


#程式碼修改
ax = fig.gca(projection = '3d') 改成
ax = fig.add_subplot(projection = '3d')

參考網址:

繪圖參數
plt.figure(figsize=(7,5))   # 顯示圖框架大小

plt.style.use("ggplot")     # 使用ggplot主題樣式
plt.xlabel("Number of cars", fontweight = "bold")                  #設定x座標標題及粗體
plt.ylabel("Number of passengers(million)", fontweight = "bold")   #設定y座標標題及粗體
plt.title("Scatter of Number of cars and Number of passengers(million)",
          fontsize = 15, fontweight = "bold")        #設定標題、字大小及粗體

plt.scatter(bus["number of cars"],                    # x軸資料
            bus["number of passengers(million)"],     # y軸資料
            c = "m",                                  # 點顏色
            s = 50,                                   # 點大小
            alpha = .5,                               # 透明度
            marker = "D")                             # 點樣式

plt.savefig("Scatter of Number of cars and Number of passengers(million).jpg")   #儲存圖檔
plt.close()      # 關閉圖表

參數說明
x必填,第一組數據 ( x 軸 )。
y必填,第二組數據 ( y 軸 )。
c資料點的顏色,支援陣列資料 ( 除了十六進位色碼,也可填入顏色代碼,例如 r、g、b、m、c、y...等,參考:color 列表 )。
s資料點的尺寸,預設和資料同大小,支援陣列資料。
marker資料點樣式,預設圓點 ( 資料點樣式代碼為 .、,、o、v...等,參考:markers 列表 )。
cmap顏色地圖,如果 c 為數據資料,會根據 c 的數據對應指定顏色 ( 參考:colormaps )。
vmin對照顏色地圖的最小值。
vmax對照顏色地圖的最大值。
alpha資料點透明度,預設 1,範圍 0 ( 完全透明 ) ~ 1 ( 完全不透明 )。
linewidths資料點外框粗細,預設無外框,支援陣列資料。
edgecolors資料點外框顏色,預設無外框,顏色設定等同 c。

2023年4月26日 星期三

還不錯用的PHP函式收集


function checkIsBetweenTime($start,$end){   //時間範圍偵測
    $date= date('H:i');
    $curTime = strtotime($date);//現在時間
    $assignTime1 = strtotime($start);//時間範圍起點
    $assignTime2 = strtotime($end);//時間範圍終點
    $result = 0;
    if($curTime>$assignTime1&&$curTime<$assignTime2){
        $result = 1;
    }
    return $result;
}

用途:偵測當前時間是否在某個時間範圍

格式範例:checkIsBetweenTime("07:00","12:00")

function mask_name($name){  //把名字馬賽克
    $len=mb_strlen($name,'utf-8');
    if ($len<3){
        $a=mb_substr($name,0, 1,'utf-8').'○';
    }else{
        for ($i=1;$i<($len-1);$i++){
            $m.='○';
        }
        $a=mb_substr($name,0, 1,'utf-8').$m.mb_substr($name,-1, 1,'utf-8');
    }
    return $a;
}

用途:為了個資法將名字中間的字改成O


//無條件進位
function ceil_dec($v, $precision){
    $c = pow(10, $precision);
    return ceil($v*$c)/$c;
    //ceil_dec(1.321,2);// 無條件進位到小數第2位=>1.33 (範例)
}


//無條件捨去
function floor_dec($v, $precision){
    $c = pow(10, $precision);
    return floor($v*$c)/$c;
    //floor_dec(1.326,2);// 無條件捨去到小數第2位=>1.32(範例)
}

用途:無條件進位或捨去至第幾位數的作法


$weekarray=array("日","一","二","三","四","五","六");
echo $weekarray[date("w",strtotime('2023-04-26'))];

用途:判斷該日期為星期幾


//清空資料夾函式和清空資料夾後刪除空資料夾函式的處理
function deldir($path){
    //如果是目錄則繼續
    if(is_dir($path)){
        //掃描一個資料夾內的所有資料夾和檔案並返回陣列
        $p = scandir($path);
        foreach($p as $val){
            //排除目錄中的.和..
            if($val !="." && $val !=".."){
                //如果是目錄則遞迴子目錄,繼續操作
                if(is_dir($path.$val)){
                    //子目錄中操作刪除資料夾和檔案
                    deldir($path.$val.'/');
                    //目錄清空後刪除空資料夾
                    @rmdir($path.$val.'/');
                }else{
                //如果是檔案直接刪除
                    unlink($path.$val);
                }
            }
        }
    }
}

用途:完整清空資料夾


function second_count($d1,$d2)      //判斷兩時間相差幾秒
{
    $d1 = strtotime ($d1) ;
    $d2 = strtotime ($d2);
    $n=round($d1-$d2);
    return $n;
}

用途:如說明,可衍伸為差異天數


關於二次扣款

 【中華電信-可二次扣款】

1.市話撥 123,轉客服人員 (非家庭用戶只能轉客服)

2.提供 營運處代號 及 用戶號碼 (代表號) 6 237***2

3.提供 用戶帳號  A376******Y3002

4.提出需要二次扣款

5.提供申請人姓名及電話

6.約10~15分鐘完成復話 

※但是學校內多支專線掛在同一個代表號,所以有可能有沒開到的狀況發生,若有發生需再撥一次電話,提供未復話的電話號碼給客服完成復話